質問

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

役に立ちましたか?

解決

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).

他のヒント

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).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top