Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response
OpenUI5 version: 1.85.0
Browser/version (+device/version): Chrome
Any other tested browsers/devices(OK/FAIL): FAIL
URL (minimal example if possible): Local project
User/password (if required and possible - do not post any confidential information here):
Steps to reproduce the problem:
Using SAP B1 OData Service layer V4 in Open UI5 Facing issue while doing list binding Failed to get contexts for /api/resource/ENTITYSETwith start index 0 and length 10 - Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response for /api/resource/ENTITYSET?$skip=0&$top=110 at e.doCheckVersionHeader (https://sapui5.hana.ondemand.com/resources/sap/ui/core/library-preload.js:4417:314) at Object. (https://sapui5.hana.ondemand.com/resources/sap/ui/core/library-preload.js:4444:415) at Object. (https://sapui5.hana.ondemand.com/resources/sap-ui-core.js:2180:9272) at p (https://sapui5.hana.ondemand.com/resources/sap-ui-core.js:2309:26828) at Object.fireWith [as resolveWith] (https://sapui5.hana.ondemand.com/resources/sap-ui-core.js:2309:27671) at A3 (https://sapui5.hana.ondemand.com/resources/sap-ui-core.js:2309:84811) at XMLHttpRequest. (https://sapui5.hana.ondemand.com/resources/sap-ui-core.js:2309:87441) sap.ui.model.odata.v4.ODataListBinding
Already checked issue listed on potal : #2686 Still we are facing issue in OData V4 Binding with UI5 What is the expected result? Binding must work, we are able to see OData-Version=4.0 in POSTMAN
What happens instead? Error comes Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response for /api/resource/
Any other information? (attach screenshot if possible) We are using node as middleware, please check below headers already set msg.headers['Content-Type'] = 'application/json;odata.metadata=minimal;charset=utf-8'; msg.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'; msg.headers['Access-Control-Expose-Headers'] = '' ; msg.headers['Access-Control-Allow-Headers'] = 'OData-Version'; msg.headers['Access-Control-Allow-Credentials'] = 'true'; msg.headers['Access-Control-Allow-Origin'] = '' ; msg.headers['Access-Control-Allow-Methods'] = '*' ; msg.headers['Access-Control-Expose-Headers'] = 'OData-Version'; msg.headers['Control-Expose-Header'] = 'OData-Version'; msg.headers['OData-Version'] = '4.0';
POSTMAN Screenshot image
POSTMAN Screenshot

UI5 App Screenshot Console Error

Can you please let us know the exact headers (both request, response) for the GET request as they appear in the developer tools for the UI5 application? If the server sends the headers and the client does not receive them, obviously something must happen "in the middle" (as it was the case with CORS in #2686).
Please find the screenshots
RequestHeader

ResponseHeader

CORS and all the CORS related headers should not play a role in your scenario as both, the Webapp and the OData service are located at localhost:62564...
You wrote that you use a NodeJs middleware, but the response header Server indicates a Jetty (J2EE) server. My guess would be that the piece of software that integrates the NodeJs server into the Jetty (some proxy servlet?) is responsible for the missing headers.
Since there is no response from the author for more than 4 weeks I'm closing the ticket.
My backend is ASP.NET, and I encountered a similar error. I was able to fix it thanks to your guidance; the issue was due to CORS. Thank you very much
Duplicate of https://github.com/SAP/openui5/issues/2686