I am new to SAP and currently working on the walkthrough tutorial of the SAPUI5 documentation and managed to get to Step 26 - Remote OData Service.
I also wanted to try this step with my own OData service from the backend system that I created for work. I simply replaced the OData service from the tutorial with the service URL of my own OData service plus I created a destination for the ABAP server.
The code in my manifest.json
file:
"dataSources": {
"mainService": {
"uri": "server-url/sap/opu/odata/sap/ZDEMO_ODATA_PRACTICE_SRV",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
"models": {
"": {
"dataSource": "mainService",
"preload": true
}
}
I wanted to display the data from the database in a simple list and created following view:
<mvc:View controllerName="dummyproject.dummyproject.controller.App"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
displayBlock="true">
<!-- ... -->
<List items="{/PersonSet}">
<!-- ... -->
</List>
<!-- ... -->
</mvc:View>
The connection is working, but I get an empty list on my screen and the following error message:
[ODataMetadata] initial loading of metadata failed
I've already seen error guides that suggest that this error has something to do with same-origin policy but I thought I could resolve it with creating a destination.
I also checked the OData service itself in the SAP GUI and tested it with the SAP Gateway client, where it works without any problems.
Does anybody know how to deal with this error or maybe has a clue what I might have done wrong?
From the Gateway's point of view you can troubleshoot such issues with the Error Log and Payload Trace. However these are mostly useful when you see a failing request in the Network tab as well in the Chrome developer tools (you didn't mention if you do or not). Error Log:
Traces
From the UI5 point of view Swadhin's answer is correct.