Which Status Code for “client requested wrong format”?
-
22-06-2021 - |
Pregunta
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
Solución
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).
Otros consejos
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).
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow