错误参数的正确 http 响应代码是什么
What is the proper http response code for bad parameters
这里是新用户。
我有一个 REST 服务,除非请求中的参数有效,否则该服务无法工作。我查看了可能的 HTTP 响应代码列表,其中 none 似乎很正确。 500 看起来不对,因为它实际上是一个预期的错误。 404 是不对的,因为请求的资源原则上是可用的。 406 特定于内容协商,这不是这里发生的事情。等等。
是否有约定发送哪个 HTTP 响应代码来表示请求由于其内容的原因而无效?
Is there a convention which HTTP response code to send to signify that the request is not valid for reasons of its content?
The 422 (Unprocessable Content) status code indicates that the server
understands the content type of the request content (hence a 415
(Unsupported Media Type) status code is inappropriate), and the
syntax of the request content is correct, but was unable to process
the contained instructions. For example, this status code can be
sent if an XML request content contains well-formed (i.e.,
syntactically correct), but semantically erroneous XML instructions.
Is it OK to use that on a general HTTP request? I had considered it, but read somehwere it is specific to WebDAV.
422的原始定义来自WebDAV(具体RFC-4918), but the IANA status code registry currently uses HTTP Semantics作为标准参考。
不识别 422 的通用 HTTP 组件应该将响应解释为 400 Bad Request,这很好。
这里是新用户。
我有一个 REST 服务,除非请求中的参数有效,否则该服务无法工作。我查看了可能的 HTTP 响应代码列表,其中 none 似乎很正确。 500 看起来不对,因为它实际上是一个预期的错误。 404 是不对的,因为请求的资源原则上是可用的。 406 特定于内容协商,这不是这里发生的事情。等等。
是否有约定发送哪个 HTTP 响应代码来表示请求由于其内容的原因而无效?
Is there a convention which HTTP response code to send to signify that the request is not valid for reasons of its content?
The 422 (Unprocessable Content) status code indicates that the server
understands the content type of the request content (hence a 415
(Unsupported Media Type) status code is inappropriate), and the
syntax of the request content is correct, but was unable to process
the contained instructions. For example, this status code can be
sent if an XML request content contains well-formed (i.e.,
syntactically correct), but semantically erroneous XML instructions.
Is it OK to use that on a general HTTP request? I had considered it, but read somehwere it is specific to WebDAV.
422的原始定义来自WebDAV(具体RFC-4918), but the IANA status code registry currently uses HTTP Semantics作为标准参考。
不识别 422 的通用 HTTP 组件应该将响应解释为 400 Bad Request,这很好。