Reputation: 151
I need to know how to pass authorization values in sap.ui.model.json.JSONModel
-> loadData()
method
API reference I am trying to execute this -
var uri = "https://sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWDEMO/ProductCollection?$format=json";
var ojsonModel = new sap.ui.model.json.JSONModel();
var oHeaders = {
"Authorization": {
"Basic": btoa('P1940678860' + 'rahul123')
}
};
ojsonModel.loadData(uri, null, true, "GET", null, false, oHeaders);
console.log(ojsonModel);
I am getting error 401 (Unauthorized)
Upvotes: 0
Views: 2288
Reputation: 3948
The headers should be given as simple object (key value pairs) without nesting. The object property name will become the header name and the property value will become the header value. The values should be of type string.
var oHeaders = {
"Authorization": "Basic " + btoa('P1940678860' + 'rahul123')
};
Upvotes: 1