cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 OData Passing User ID and PWD, ES5 system

0 Kudos

Hi,

Was trying to access ES5 system using OData,

but getting error in passing User ID and Password.

Can you please help.

Getting errors in debug window as

"jquery-dbg.js:9203 GET https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet/ 401 (Unauthorized)"
"Failed to load https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet/: No 'Access-Control-Allow-Origin' 
header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 401." 

The code is below.


<script>
var sURL1 = "https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet/";
var sUserID = "S000XXXXX";
var sPassword = "SXXXXX"
var oModel = new sap.ui.model.json.JSONModel(sURL1, true, {user:sUserID,password:sPassword});
sap.ui.getCore().setModel(oModel);
var oTable = new sap.m.Table("tableID", {
columns : [ new sap.m.Column ({ 
header:[ new sap.m.Label ({text: "Product ID"})]}),
new sap.m.Column ({ header :[ new sap.m.Label ({text: "Type Code"})]})
]
});
oTable.bindItems("/value", new sap.m.ColumnListItem("listItem",{
cells:[ new sap.m.Text({text: "{ProductID}"}),
new sap.m.Text ({text: "{TypeCode}"})
]}));
oTable.placeAt("content");</script>

Accepted Solutions (0)

Answers (1)

Answers (1)

irfan_gokak
Contributor
0 Kudos

Hi,

It's cross origin issue. Please define your odata service in manifest.json/Component.js

Thanks,

Irfan G.