Wednesday, June 21, 2017

HttpResponseMessage to an MVC Controller causes: Incorrect Content-Type: application/json; charset=utf-8

This error ended up having more to do with the listening ear than what was talking in. The DTO below ended up with a bunch of null values.

[HttpPost]
[Produces("application/json")]
[Route("foo/bar/baz/")]
public string Whatever(MyDto myDto)
{

 
 

This change made the problem go away:

[HttpPost]
[Produces("application/json")]
[Route("foo/bar/baz/")]
public string Whatever([FromBody] MyDto myDto)
{

No comments:

Post a Comment