Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$batch failed - Error: Expected 'OData-Version' header with value '4.0' but received value 'null' in response for http://localhost:5000/odata/$batch #3601

Closed
siasty opened this issue Sep 27, 2022 · 6 comments

Comments

@siasty
Copy link

siasty commented Sep 27, 2022

Hi, I have a problem with batch request
image
but in respod in batch is OK... and return data and also odata version
image
image
what is wrong?

@ThomasChadzelek
Copy link
Member

Hello @siasty !

Thanks for using OData V4! We apologize for any inconvenience caused!

I'm terribly sorry, but I cannot spot any mistake here. Everything looks fine, no idea why this fails. Please try to debug.

Best regards,
Thomas

@siasty
Copy link
Author

siasty commented Sep 28, 2022

Hi @ThomasChadzelek thanks for the quick reply, can you help me because I don't know what to look for
image

what scope should have odata-version ?

I have no odata-version only in request body but this function should not get from the response headers ?

@siasty
Copy link
Author

siasty commented Sep 28, 2022

is it possible to set this parameters "bVersionOptional" ? after changing to true, odata was parsed
image

@UweReeder
Copy link
Member

Hi @siasty,

It looks as if that is a CORS request. But CORS regulates the visibility of the response headers in JavaScript via the header "Access-Control-Expose-Headers". For OData V4 to work with CORS, "OData-Version" must be given here.

You should also allow X-CSRF-Token, ETag and SAP-Messages.

Best Regards
Uwe

BTW. The scope of fnGetHeader in the screenshot has the response headers in "a" and the request headers in "b". So only the Content-Type response header is visible to OData V4, as it is a CORS-safelisted response header.

@siasty
Copy link
Author

siasty commented Sep 28, 2022

you're right I added Access-Control-Expose-Headers to the controler odata And it works. thx.

@boghyon
Copy link
Contributor

boghyon commented Aug 6, 2024

Duplicate of #3150, #2686, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants