-
Notifications
You must be signed in to change notification settings - Fork 4
/
234.txt
148 lines (109 loc) · 5.96 KB
/
234.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
[1] [DFN[[CODE(HTTP)[[[422]]]]]] ([DFN[[[Unprocessable Entity]]]])
は、[[要求]]の [[payload body]] に含まれているデータが構文的には正しいものの、
内容が仕様的に正しくなく処理できないことを表す[[状態符号]]です。
* 仕様書
[REFS[
- [3] '''[CITE@en[RFC 4918 - HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)]] ([TIME[2014-09-21 17:04:59 +09:00]] 版) <http://tools.ietf.org/html/rfc4918#section-11.2>'''
- [12] [CITE@en[RFC 5789 - PATCH Method for HTTP]] ([TIME[2014-09-22 15:11:26 +09:00]] 版) <http://tools.ietf.org/html/rfc5789#section-2.2>
]REFS]
* 意味
[4] [CODE(HTTP)[[[422]]]] は、[[鯖]]が[[要求]]の [[payload body]] の
[[MIME型]]は理解でき、構文的には正しかったものの、
記述されている指示に従って処理することはできなかったことを表す[[状態符号]]です [SRC[>>3]]。
;; [2] [[MIME型]]に対応していない時は、 [CODE(HTTP)[[[415]]]] がより適当です [SRC[>>3]]。
;; [5] [[payload body]] が構文的に正しくない時は、 [CODE(HTTP)[[[400]]]]
がより適当です [SRC[>>3]]。
;; [11] [[整形式]]であっても[[要素]]の構造が仕様上正しくない時には [CODE(HTTP)[[[400]]]]
を返すともされており、 [CODE(HTTP)[[[422]]]] との使い分けはよくわかりません。
([[[CODE(HTTP)@en[PROPFIND]]]>>44]参照。)
;; [10] [[外部実体参照]]が含まれ、[[鯖]]がこれを拒絶したい時は、
[CODE(HTTP)[[[403]]]] を使うことになっています。
* 文脈
[13] [CODE(HTTP)@en[[[PATCH]]]] [[要求]]の [[payload body]] を理解できるものの、
処理はできない場合には、 [CODE(HTTP)[[[422]]]] [[応答]]を返す[['''べきです''']] [SRC[>>12]]。
[EG[
[14] 例えば[[パッチ文書]]を適用した結果 [[XML文書]]が[[整形式]]でなくなるなら、
[CODE(HTTP)[[[422]]]] [[応答]]を返すことができます [SRC[>>12]]。
]EG]
* 歴史
[FIG(quote)[
[FIGCAPTION[
[7] RFC 2518 (WebDAV) 10.3 422 Unprocessable Entity
]FIGCAPTION]
> The 422 (Unprocessable Entity) status code means the server
understands the content type of the request entity (hence a
415(Unsupported Media Type) status code is inappropriate), and the
syntax of the request entity is correct (thus a 400 (Bad Request)
status code is inappropriate) but was unable to process the contained
instructions. For example, this error condition may occur if an XML
request body contains well-formed (i.e., syntactically correct), but
semantically erroneous XML instructions.
[CODE(HTTP)[422]] (処理不能実体) 状態符号は、
サーバーが要求実体の内容型は理解した
(従って [CODE(HTTP)[[[415]]]] (未対応の媒体型) 状態符号は不適切である)
し、要求実体は正しい (従って [CODE(HTTP)[[[400]]]] (悪い要求)
状態符号は不適切である) ものの含まれている指示を処理することができなかったことを意味します。
例えば、 XML 要求本体が整形式である (つまり構文的には正しい)
が意味的に誤っている XML 指示のときにこの誤り状況が発生するかもしれません。
]FIG]
[8] [[S-HTTP]] は別の意味 ([DFN[[[SHTTP Proxy Authentication Required]]]])
で使っていました [SRC[>>423]]。
[REFS[
- [423] [CITE@en[RFC 2660 - The Secure HyperText Transfer Protocol]]
( ([TIME[2013-07-20 22:21:48 +09:00]] 版))
<http://tools.ietf.org/html/rfc2660#section-5.2.4>
]REFS]
* 実装
[9] [[要求]]で [[JSON]] を求める [[Web API]] で、入力が期待される構造でなかった時に
[CODE(HTTP)[[[422]]]] [[応答]]が返されることがよくあります。
[15] [CITE@en[Linked Data Patch Format]]
([TIME[2015-03-04 15:20:56 +09:00]] 版)
<https://dvcs.w3.org/hg/ldpwg/raw-file/ldpatch/ldpatch.html#h-error-handling>
[FIG(quote)[
[FIGCAPTION[
[16] [CITE@en[RFC 7482 - Registration Data Access Protocol (RDAP) Query Format]]
([TIME[2015-03-26 08:10:36 +09:00]] 版)
<https://tools.ietf.org/html/rfc7482#section-4.1>
]FIGCAPTION]
> If a server receives a search request but cannot process the request
> because it does not support a particular style of partial match
> searching, it SHOULD return an HTTP 422 (Unprocessable Entity)
> '''['''RFC4918''']''' response. When returning a 422 error, the server MAY also
> return an error response body as specified in Section 6 of '''['''RFC7483''']'''
> if the requested media type is one that is specified in '''['''RFC7480''']'''.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[6] [CITE@en[Uber API Reference Guide]]
([TIME[2015-09-25 03:53:01 +09:00]] 版)
<https://developer.uber.com/v1/api-reference/>
]FIGCAPTION]
> 422 Invalid request. The request body is parse-able however with invalid content or there are issues with a rider's user account.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[17] [CITE[Asterisk Project : Asterisk 12 Applications REST API]]
([TIME[2014-10-09 21:00:13 +09:00]])
<http://www.hiastar.com/download/Asterisk-Admin-Guide/Asterisk-12-Applications-REST-API_26478371.html>
]FIGCAPTION]
>
> 422 - Event source does not exist.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[18] [CITE[Asterisk Project : Asterisk 12 Bridges REST API]]
([TIME[2014-10-09 21:00:17 +09:00]])
<http://www.hiastar.com/download/Asterisk-Admin-Guide/Asterisk-12-Bridges-REST-API_22773911.html>
]FIGCAPTION]
>
> 422 - Channel not in Stasis application
]FIG]
[FIG(quote)[
[FIGCAPTION[
[19] [CITE@en[API reference overview | Postmark Developer Documentation]]
( ([[Wildbit, LLC]]著, [TIME[2017-01-19 01:49:47 +09:00]]))
<http://developer.postmarkapp.com/developer-api-overview.html>
]FIGCAPTION]
> 422 — Unprocessable Entity
> Something with the message isn’t quite right, this could be malformed JSON or incorrect fields. In this case, the response body contains JSON {ErrorCode: 405, Message: "details"} with an API error code and message containing details on what went wrong.
]FIG]