新用戶在這里。
我有一個 REST 服務,除非請求中的引數有效,否則該服務無法作業。我查看了可能的 HTTP 回應代碼串列,但似乎沒有一個是完全正確的。500 似乎不對,因為它實際上是一個預期的錯誤。404 是不對的,因為請求的資源原則上是可用的。406 特定于內容協商,這不是這里發生的事情。等等。
是否有約定發送 HTTP 回應代碼來表示請求由于其內容的原因而無效?
uj5u.com熱心網友回復:
是否有約定發送 HTTP 回應代碼來表示請求由于其內容的原因而無效?
422 無法處理的內容
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.
可以在一般 HTTP 請求上使用它嗎?我曾考慮過,但讀到它是特定于 WebDAV 的。
422 的原始定義來自 WebDAV(特別是RFC-4918),但IANA 狀態代碼注冊表目前使用HTTP Semantics作為標準參考。
不能識別 422 的通用 HTTP 組件應該將回應解釋為400 Bad Request,這很好。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/440216.html
