on ‎2016 May 19 6:44 PM
Hello there,
i am developing in IntelliJ IDEA with an OpenUI5 SDK 1.36.5. While trying to access my Odata Service with an ODataModel i get continuously an access error seeing below:
What have i done?
Too make it short:
To check the headers i use Postman. With http://[server]:[port]/sap/opu/odata/sap/ZUI5_IW74874_TEST_SRV/VBAKUK_UI5Set/ and an Basic Authorization Header (credentials to get access) i get all the data i want plus the "access-control-allow-origin →*" header.
Now to the code i have written
<script>
sap.ui.localResources("sap_ui5_playground");
sap.ui.localResources("util");
sap.ui.localResources("i18n");
var oView = sap.ui.view({
viewName: "sap_ui5_playground.Main",
type: sap.ui.core.mvc.ViewType.HTML
});
oView.placeAt("content");
</script>
<script>
var url = "http://[host]:[port]/sap/opu/odata/sap/ZUI5_IW74874_TEST_SRV/"; //url as full address
var oModel = new sap.ui.model.odata.ODataModel(url, false, "[username]", "[password]"); //name and pw as plain text here
sap.ui.getCore().setModel(oModel, "odata");
var oTable = new sap.ui.table.Table({
width: "100%",
title: "Daten aus dem SAP mit OData",
editable: true,
items: "{odata>/VBAKUK_UI5Set?$format=json&sap-client=201}"
});
oTable.addColumn(new sap.ui.table.Column({
id: "Mandt",
label: new sap.ui.commons.Label({
text: "Mandt"
}),
template: new sap.ui.commons.TextView({
text: "{odata>Mandt}"
})
}));
[more columns]
oTable.setModel(oModel);
oTable.placeAt("content");
I tried several ways in coding to fix the issue yet, nothing worked. If you know any way further to help me i would really appreciate it. I am open for every hint you're might be able to give, so don't hesitate to answer
Best regards,
Max
Request clarification before answering.
This is your browser preventing a cross origin request. You can either use a proxy to load the data, turn off your browser security, or use SAP Web IDE.
HTTP access control (CORS) - HTTP | MDN
Regards,
Jamie
SAP - Technology RIG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
UI5 provides a proxy, which I have only ever used in eclipse
You can turn off cors in chrome by starting it with --disable-web-security --user-data-dir
Regards,
Jamie
SAP - Technology RIG
I try to avoid disabling CORS because it should be used as most independent as it is possible now. If i can only use it with that its not very...usable i would say additionally, i'm coding on OS X so it's not even possible to do that as easily as it is on Windows
I will take a look over the UI5 Sample Proxy. It looks like a nice try for now. Thanks for that
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.