openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response

Open soyuztechnologies opened this issue 5 years ago • 7 comments

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

soyuztechnologies avatar Jan 03 '21 07:01 soyuztechnologies

POSTMAN Screenshot image

UI5 App Screenshot Console Error image

soyuztechnologies avatar Jan 03 '21 07:01 soyuztechnologies

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).

codeworrior avatar Jan 03 '21 10:01 codeworrior

Please find the screenshots RequestHeader image

ResponseHeader image

soyuztechnologies avatar Jan 03 '21 12:01 soyuztechnologies

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.

codeworrior avatar Jan 03 '21 15:01 codeworrior

Since there is no response from the author for more than 4 weeks I'm closing the ticket.

flovogt avatar Mar 01 '22 07:03 flovogt

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

trevor-media avatar Jul 20 '24 11:07 trevor-media

Duplicate of https://github.com/SAP/openui5/issues/2686

boghyon avatar Aug 06 '24 10:08 boghyon