What status code should a REST service return in response to a POST request containing a malformed / unparseable message body?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
400 Bad Request
Straight from the specification:
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
Alternatively, if you need a more specific status you can create your own 4XX status for whatever API you might be designing.
回答2:
400 - Bad Request
From Hypertext Transfer Protocol -- HTTP/1.1 (RFC-2616):
400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
回答3:
I'd say 412 Precondition Failed