SAPUI5: OData V2 returns error "The Data Services Request could not be understood due to malformed syntax"

6.1k Views Asked by At

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) {
      // ...
    }
  });
},
1

There are 1 best solutions below

0
On

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.