422 Unprocessable Content
HTTP 422 Unprocessable Content
(无法处理的内容)客户端错误响应状态码表示服务器理解请求内容的类型,请求内容的语法也正确,但无法处理其中包含的指令。
收到 422
响应的客户端应预期,不作修改地重复请求也会遇到相同的错误。
状态
http
422 Unprocessable Content
示例
SHA 验证失败
以下示例发出一个请求来更新文件内容(基于 GitHub 的 API)。content
字段是 Base64 编码的,每 60 个字符使用一个 \n
换行符,并以一个 \n
结束字符串。
http
PUT /repos/mdn/content/contents/README.md HTTP/1.1
Host: api.example.com
Accept: application/vnd.github+json
Authorization: Bearer abcd123
Content-Type: application/json
Content-Length: 165
{
"message": "My commit",
"content": "WW9zaGkgd2FzIHRoZXJlLCBzbyB3ZXJlIEF5c2UsIGFuZCBCZWxnaW4uIEl0\nIHdhcyBncmVhdCE=\n",
"sha": "80e73970fdee49dbdbac27c1f565d1eb1975d519"
}
在此实现中,服务器严格要求符合 RFC 4648 的 Base64 编码内容(使用严格编码方法)。服务器会返回 422
Unprocessable Content 响应,并且 message
字段提供了关于验证错误的上下文。
http
HTTP/1.1 422 Unprocessable Content
Date: Fri, 28 Jun 2024 12:00:00 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 187
{
"message": "content is not valid Base64",
"documentation_url": "https://docs.example.com/en/rest/repos/contents"
}
规范
规范 |
---|
HTTP 语义 # status.422 |