question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Net.Http: The format of value 'application/json; charset=utf-8' is invalid.

See original GitHub issue

Repro 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-typeand 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:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mathewccommented, Sep 14, 2016

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

0reactions
Clockwork-Musecommented, Mar 6, 2018

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 to application/json seems to be overriden)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found