Search code examples
odatasapui5

Not able to call Odata Service in UI5


I am calling Odata service for my UI5 application. I am using below mentioned code for creating the model.

var oModel = new sap.ui.model.json.JSONModel("https://<>/sap/opu/odata/SIE/MED_TEST_OSIRIS_SRV/SalesOrderSet?$format=json");
//Getting the Data and putting in list model
sap.ui.getCore().setModel(oModel,"table");

With this code , I can call the Odata and display the results in a table.

But now when I am applying filter like this :

https://<>/sap/opu/odata/SIE/MED_TEST_OSIRIS_SRV/SalesOrderSet?$filter=Country_SP eq 'DE'

I can get the results in browser's address bar but not in the code like :

var sUrl = "https://<>/sap/opu/odata/SIE/MED_TEST_OSIRIS_SRV/SalesOrderSet?$filter=Country_SP eq 'DE'";

var oModel = new sap.ui.model.json.JSONModel(sUrl);

what I am doing wrong ? I can filter the results in the browser with the same url :(

Regards, Mayank


Solution

  • Try with synchronous call.

    var oModelData = new sap.ui.model.json.JSONModel();

    oModelData.loadData(sUrl, null, false);