Accepted varieties of application/json Content-type in .Net core 3.1

Viewed 292

I recently upgraded my API which consumes only Json input from .Net core 2.1 to .Net core 3.1

[Route("")]
[Authorize]
public class ProductsController : Controller
{
    [HttpPost]
    [Consumes("application/json")]
    public async Task<ActionResult> Post([FromBody] object input)
    {
       //logic code here
    }
}

One behavioral change I have noticed when using [Consumes("application/json")] is that .Net core was responding with 415 status code for the following varieties of content-type header but now they are accepted same as application/json.

application/*+json

application/json-patch+json

Any reason for this change? can we know the full list of accepted varieties? I am planning to return the same 415 status code for the newly accepted varieties because I don't want my API behavior to change when depending on the default .Net Model binding.

Note: when testing with .Net core 2.2; seems like the change happened in .Net core 2.2 as it behaves same as .Net Core 3.1

0 Answers
Related