cancel
Showing results for 
Search instead for 
Did you mean: 

Facing issue while calling Function Import of a Service URI

Sijin_Chandran
Active Contributor
0 Kudos

Hi All,

I am facing issue while calling a Function Import.

Below is my syntax,

            var serviceUri = "https://******************/sap/opu/odata/SAP/ZTSUPRTSTATC_GW_SRV/";
            var oModel = new sap.ui.model.odata.ODataModel(serviceUri, true, "user", "password");
            sap.ui.getCore().setModel(oModel);
            
            var parameters = { method:"GET", 
                               urlParameters : { LowDate : firstDay,HighDate : lastDay },
                               success:function(oData, oResponse) {                  
                                   console.log(oResponse);
                                   console.log(oData);
                                   var valor = oData.results[0].Name;
                                   alert(valor); //"ok"
                                       }, 
                               error:function(oError){
                                     alert("Data retrieval was not successful!");
                                     } 
                             };

oModel.callFunction("PersonTaskTimespend", parameters );
View Entire Topic
Sijin_Chandran
Active Contributor
0 Kudos

Hi Everyone,

Very thanks for your time.

The issue was CORS issue and got it rectified by making the following changes to Service URI,

//          var serviceUri = "https://*******.*****.******:####/sap/opu/odata/SAP/ZTSUPRTSTATC_GW_SRV/";
            var serviceUri = "proxy/https/*******.*****.******:####/sap/opu/odata/SAP/ZTSUPRTSTATC_GW_SRV/";

So changing https:// with proxy/https/ made the code work.

I had faced the issue while working using WEB IDE , but there in browser Console it was clearly mentioned that CORS issue has been encountered and I got it rectified by prefixing https://cors-anywhere.herokuapp.com/

but now am using Eclipse and here it was not highlighted in browser Console that the issue was CORS.

Thanks,

Sijin