File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -142,3 +142,53 @@ that wish to support these clients are recommended to treat `POST` requests as
142
142
` PATCH ` requests if the client includes the ` X-HTTP-Method-Override: PATCH `
143
143
header. This allows clients that lack ` PATCH ` support to have their update
144
144
requests honored, simply by adding the header.
145
+
146
+
147
+ ## Asynchronous Processing <a href =" #asynchronous-processing " id =" asynchronous-processing " class =" headerlink " ></a >
148
+
149
+ Consider a situation when you need to create a resource and the operation takes long time to complete.
150
+
151
+ The request ** SHOULD** return a status ` 202 Accepted ` with a link in Header/Location.
152
+
153
+ ``` text
154
+ HTTP/1.1 202 Accepted
155
+ Location: https://example.com/photos/queue/5234
156
+ Content-Type: application/vnd.api+json
157
+ ```
158
+
159
+ The location gave ** SHOULD** return ` 200 Ok ` with the status of the selected job. The body ** MAY** contains ` "actions" ` to manage the job.
160
+
161
+ ``` json
162
+ {
163
+ "links" : {
164
+ "self" : " /photos/queue/5234"
165
+ },
166
+ "data" : {
167
+ "type" : " queue job" ,
168
+ "id" : " 5234" ,
169
+ "status" : " Process failed, see errors" ,
170
+ "errors" : [
171
+ {
172
+ "code" : " too_long" ,
173
+ "field" : " /photos/title"
174
+ },
175
+ {
176
+ "code" : " invalid_format" ,
177
+ "field" : " /photos/file01"
178
+ }
179
+ ]
180
+ },
181
+ "actions" : {
182
+ "cancel" : " /photos/queue/5234/cancel" ,
183
+ "delete" : " /photos/queue/5234/delete"
184
+ }
185
+ }
186
+ ```
187
+
188
+ When job process is done the location gave ** SHOULD** return ` 303 See other ` with the location of the data in Header/Location.
189
+
190
+ ``` text
191
+ HTTP/1.1 303 See other
192
+ Location: https://example.com/photos/4577
193
+ Content-Type: application/vnd.api+json
194
+ ```
You can’t perform that action at this time.
0 commit comments