1

I'm trying to read an OData but I'm getting this error and I don't understand why:

OData error messages

The function which I invoke is the below:

_getHanaData: function() {
  var xsODataModel = new sap.ui.model.odata.v2.ODataModel("/catalog/");
  // ...
},

As shown in the image below, metadata are retrieved and the status of request is 200:

OData service document metadata response

3
  • 3
    Your service is an OData V4 service, try sap.ui.model.odata.v4.ODataModel. Oct 18, 2021 at 12:29
  • 2
    Also it is more reliable to declare your models in manifest.json and access them via getModel method of the view.
    – astentx
    Oct 18, 2021 at 12:41
  • 2
    The OData specification has versions which are not compatible with each other. In your app, you're telling UI5 to fetch V2-compliant OData service document. But what your OData service actually delivers is V4-compliant. Oct 18, 2021 at 14:28

1 Answer 1

1

As suggest in the comments, the problem is the OData version. I've fixed the issue using sap.ui.model.odata.v4.ODataModel. In the fourth version of OData, the right way to perform CRUD requests is by using bindings. I've found this official tutorial very useful in order to understand how they work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.