REST: http 204 status code for polling for a resource after creation 201

I have a request (POST) that creates a resource. This resource takes a long time to create (up to several hours), but its identifier is created immediately.

It seems to me the most appropriate thread:

  • POST / thing - response 201 Created with "URI for the resource specified by the location header field" (according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html )

  • Start a GET / thing / id poll, to which the answer should respond:

    • Until the resource has been prepared - 204 No content

    • As soon as the resource is ready - 200 OK with the resource returned to the response body

I am looking for opinions / advice because I base my opinion on (a lot) of reading and, moreover, on experience, and this seems different from most recommendations to initially return 202 Accepted and use 204 only in response to http DELETE

+3
source share
1 answer

You can return 202 Acceptedto POST:

The request has been accepted for processing, but processing has not yet been completed. The request may or may not be subsequently applied, as this may be prohibited when processing actually takes place.

, , , - Status, , , GET. .

, , 202 GET .

"", , 204 No Content, ", " " , ".

+4

All Articles