Question

Which HTTP Status Code is the best to use for "Client requested a wrong format", e.g. the client requested format=json and the data is only available as XML? I tend to use 406 but this refers to the Accept heders, whereas the format is given as parameter in the query string in my usecase.

Is 406 the right code here anyway?

Thanks

Was it helpful?

Solution

My advice is always to keep it simple. Send a 400 Bad Request and in the response body add a message indicating why the request was bad (ie format json not available).

OTHER TIPS

No, if you don't have content for the request URI the most obvious choice is simply 404 (you can put details into the payload).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top