Home Articles Details

The content in the request produced errors while parsing. Check that the content is correctly formatted for the Content-Type provided.


Question: How do you solve for an error in Asp.Net Core that says "The content in the request produced errors while parsing. Check that the content is correctly formatted for the #Content-Type provided."?

Login to See the Rest of the Answer

Answer: Take a deeper look at the request #payload going to the API or a #Web Service, inspect the headers and you will find that the #ContentType is truncated. This can be an issue with the specific Http Client library you are using.

If you are using #RestSharp to call a remote API in C-Sharp, make sure that you pass in the #Payload through the Body. See the code below:

//Avoid the code below 
request.AddParameter("ParameterName", Payload, ParameterType.RequestBody);

//Recommended code below
request.AddBody(Payload, contentType: "application/json");

If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2023 - ErnesTech LLC- Privacy