on 12-27-2016 12:55 PM
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 );
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Might work if you change the parameters of your odatamodel.
https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.odata.ODataModel.html#constructor
var oModel =new sap.ui.model.odata.ODataModel(serviceUri, {user:"user", password:"password"});
Also, use odatamodel version 2(sap.ui.model.odata.v2.ODataModel) whenever possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
deploy to the server where the odata service is to run your app, if not, you have to know how to use proxy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sijin,
Please check with the below code :
oModel.callFunction("/EmployeeSet", "GET", null, null, function (
oData, oResponse) {
alert("ok");
}, function (oError) {
alert("err");
});
Kindly let me the if issue still exist.
and if possible paste some screen shot.
Thanks,
Deepak.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
are u sure it is syntax error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am facing Syntax error for the below line of code,
oModel.callFunction("PersonTaskTimespend", parameters );
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.