Had a tricky issue with a customer using our API (implemented using ASP.Net Web API) where by they were using the application/json content type in their requests, but were accidentally appending a trailing semicolon e.g.
Content-Type: application/json;
Instead of normal exception e.g.
No MediaTypeFormatter is available to read an object of type 'foo' from content with media type 'application/json;'
The request is actually handled as if a valid media type was provided, but then fails to bind the model (e.g. the foo object ends up as null).
I think this should either bind correctly, or throw an error (I would prefer it displayed an error).
I see similar behavior when using other variations of application/json e.g. all caps "APPLICATION/JSON" as a content type in the request also causes the same behavior of model being null, but not the typical "no formatter is available to read" etc. errors.
Thoughts?
Comments: Dup of issue 281.
Content-Type: application/json;
Instead of normal exception e.g.
No MediaTypeFormatter is available to read an object of type 'foo' from content with media type 'application/json;'
The request is actually handled as if a valid media type was provided, but then fails to bind the model (e.g. the foo object ends up as null).
I think this should either bind correctly, or throw an error (I would prefer it displayed an error).
I see similar behavior when using other variations of application/json e.g. all caps "APPLICATION/JSON" as a content type in the request also causes the same behavior of model being null, but not the typical "no formatter is available to read" etc. errors.
Thoughts?
Comments: Dup of issue 281.