Error: Expected 'OData-Version' header with value '4.0' but received value 'null'
OpenUI5 version: SAPUI5 Distribution: 1.70.0 (Build von 11.09.2019 07:41:00) OpenUI5 Version: 1.70.0 (Build von 09.09.2019 16:01:00) Benutzeragent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 App-URL: http://localhost:5500/webapp/index.html
Browser/version (+device/version): Google Chrome: Version 76.0.3809.132 (Offizieller Build) (64-Bit)
Any other tested browsers/devices(OK/FAIL): Firefox: FAIL MS Edge: FAIL
Minimal example if possible
<Table ... items="{path: 'middlewareModel>/ProductSearch'}"></Table>
Steps to reproduce the problem:
- Register an OData datasource (.NET Core 2.2, OData-Version: v4.0) and model in the manifest.json
- Create view and assign ODataModel to a table
- Run application in browser
- Error is thrown
What is the expected result? The result of the ODataModel should be displayed in the table.
What happens instead? The following error occured: Failed to get contexts for http://localhost:49640/odata/ProductSearch with start index 0 and length 10 - Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response for http://localhost:49640/odata/ProductSearch?$skip=0&$top=10
Any other information? (attach screenshot if possible)
I checked the response headers in Google Chrome (see attached Screenshot):
It works with an older version of SAP UI5 (tested with 1.44.12 for example).
Hello everybody,
I found out that this was a CORS error. I have inserted the following header into the OData service:
Access-Control-Expose-Header: 'OData-Version'
Otherwise, CORS does not allow OpenUI5 to read the contents of the OData-Version header.
it working in my case, thanks you so much
thanks for the answers guys it worked on my end