openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

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

Open jonas-trettin opened this issue 7 years ago • 3 comments

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:

  1. Register an OData datasource (.NET Core 2.2, OData-Version: v4.0) and model in the manifest.json
  2. Create view and assign ODataModel to a table
  3. Run application in browser
  4. 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): image It works with an older version of SAP UI5 (tested with 1.44.12 for example).

jonas-trettin avatar Sep 23 '19 15:09 jonas-trettin

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.

jonas-trettin avatar Sep 24 '19 09:09 jonas-trettin

it working in my case, thanks you so much

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

thanks for the answers guys it worked on my end

bencyubahiro77 avatar Oct 21 '24 06:10 bencyubahiro77