System.Net.Http: The format of value 'application/json; charset=utf-8' is invalid.
See original GitHub issueRepro steps
Provide the steps required to reproduce the problem
context.res = {
headers : { "Content-Type" : "application/json; charset=utf-8" },
body : '{"foo":"bar"}',
status : 200
};
context.done();
Expected behavior
application/json; charset=utf-8
is a valid content-type
header and there should be no error.
I have a valid JSON string and I would like to pass it directly with the content-type
Actual behavior
Error after function execution :
Exception while executing function: Functions.test. System.Net.Http: The format of value ‘application/json; charset=utf-8’ is invalid.
Known workarounds
Not setting content-type
and passing json as poco in body :
context.res = {
headers : {},
body : { foo: "bar" },
status : 200
};
context.done();
Related information
- Programming language used : JavaScript with Node.js
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
c# - API Get requires Content-Type application/json;charset ...
Net Http Client I get the error: System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.' Is there ...
Read more >error: The format of value 'application/json; charset=utf-8' is ...
Exception Details: Server Error in '/' Application. The format of value 'application/json; charset=utf-8' is invalid. Description: An unhandled exception ...
Read more >Problem of URL Submission to Bing. - Microsoft Q&A
It throws this error as below: System.FormatException: The format of value 'application/json; charset=utf-8' is invalid. at System.Net.Http ...
Read more >API Get requires Content-Type application/json;charset= ...
Net Http Client I get the error: System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'.
Read more >POST request - invalid content type "text;charset=UTF-8"
Locally on my system I got this exception: org.springframework.http.InvalidMediaTypeException: Invalid mime type "text;charset=UTF-8": does not contain '/'.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yvele Agreed. I just fixed this in https://github.com/Azure/azure-webjobs-sdk-script/commit/fabcfc371add772f6791b30673e30f8578f7b287 and it will go out with our next release. Thanks.
For that matter, attempting to set the header to
application/json; charset=utf-8
in the Java runner is yielding a 406 status (setting it toapplication/json
seems to be overriden)