2

I'm trying to use OData V2 as suggested in this comment.

The issue is whenever I use sap.ui.model.odata.v2.ODataModel rather than the deprecated sap.ui.model.odata.ODataModel, I get this error from SAP Gateway Error Log

The Data Services Request could not be understood due to malformed syntax

Controller:

sap.ui.define([
  "sap/ui/core/mvc/Controller",
  "sap/ui/model/odata/v2/ODataModel",
  // ...,
], function(Controller, ODataModel/*, ...*/) {
  "use strict";

Here is when I called OData V2:

onPressButton1: function(){
  var vEntityURL = "/CustomerSet(ID='000')";
  var sServiceUrl = "/Customers_SRV/";
  var oServiceModel = new ODataModel(sServiceUrl, true);
  oServiceModel.read(vEntityURL, {
    success: function(oData) {
      // ...
    }
  });
},
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Abdulelah
  • 77
  • 3
  • 10
  • 1
    In a situation like that it can be useful to use the developer tools of your web browser (F12) to check the network activity when you use your application and see what requests to what URLs your application is actually performing. Make sure the URL being requested when you press on the button does actually make sense. Does it go to the right host? Do you have an oData webservice on that path? Is it spelled correctly? – Philipp Jul 23 '20 at 14:02
  • That's exactly what I did but the network tab shows me "batch" error. The path is spelled correctly because when I use the deprecated OData, I get no error. And the call reaches the SAP server since I can see the error log from there as well. – Abdulelah Jul 25 '20 at 15:30
  • So it works with oData v1, you say? Is it possible that the service on the server doesn't support the oData v2 protocol? – Philipp Jul 25 '20 at 19:50
  • 1
    did you try to set the oServiceModels `useBatch` property to false before reading, also, can you post the output of /IWFND/ERROR_LOG. – Michael Schönbauer Jul 27 '20 at 07:13
  • Is this issue still relevant? If so, did `useBatch: false` in the model constructor settings help? – Boghyon Hoffmann Dec 18 '20 at 16:00

1 Answers1

0

This is batch error. Your entity set is not supporting batch calls. Make sure that allows batch call or set use batch - false as below,

oServiceModel.setUseBatch(false);

This will work for you.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77