Search code examples
javascriptodatasapui5

Browser adds $metadata to OData call


I try to consume OData service using SAPUI5 framework.

When I tested my app on localhost, I did as follows:

var oModel = new sap.ui.model.odata.ODataModel("proxy/http/services.odata.org/V3/(S(ql0iexfh2tyudc5p4qhx5gdf))/OData/OData.svc");

and it worked fine.

But when I uploaded the app to the cloud platform, I got the following error:

GET https://<accountname>.hana.ondemand.com/OData/proxy/http/services.odata.org/V3/(S(ql0iexfh2tyudc5p4qhx5gdf))/OData/OData.svc/$metadata 500 (Internal Server Error)

If I use https://services.odata.org/... in OData Model's declaration, I get another error:

OPTIONS https://services.odata.org/V3/(S(ql0iexfh2tyudc5p4qhx5gdf))/OData/OData.svc/$metadata 501 (Not Implemented)

It looks like it adds for some reason $metadata to the call and the call doesn't work.

How should I declare the OData service's URI to get it work from the cloud platform?


Solution

  • The problem is that I didn't have properly defined destination.

    I'm still looking for a solution about how to add destination using Eclipse IDE, but this particular question may be considered answered.