odatasapui5database-metadatahana-xsxsodata

ODataModel error: Invalid metadata document (Initial loading of metadata failed)


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


Solution

  • 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.