Skip to Content
0
Jun 29, 2018 at 11:12 AM

SAPUI5 OData Passing User ID and PWD, ES5 system

494 Views

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>