I have the HTTP endpoint with the optional body (OrderRequest):
[HttpPost]
public async Task<ActionResult> Index(OrderRequest? request = null)
{
//...
}
If sending a request in which Content-Type header is not specified, then 415 (Unsupported Media Type) error will appear.
What can I do to allow requests without a body and media type?
Of course, to solve it I could just add the appropriate media type on the client side. But the problem is that the previous version of this endpoint didn't require any request body and therefore media type was not required as well. So in order to ensure backward compatibility, I need to configure this endpoint to be able to accept requests as earlier (without a request body and media type).