I have a query that is expected to take several hours and I cannot fully determine the ENTIRE stream. I know that this has been discussed several times, including here , but found nothing to answer the questions below (convincingly).
What i know:
- I will do
POST /mysomethings - The response will be
202 Acceptedwith a heading Locationthat will contain the full URL where the status can be found (for example, https://api.example.com/statuses/somestatusuuid ). - Then the client can poll the status URL and get a response
200 OKwith the response body containing something like{ statusId: someid, status: somestatusstring, description: somestatusdescriptionstring }
To keep things simple and focused, I ignore how authorization will be performed for these requests.
My question is:
What should I do if the resource for the initial request is ready (say, this means that status = "complete").
The best I can come up with is one of the following:
In response to the state, an additional key is also included (after state = "full"), for example myresourceId: someuuid, and then the client can makeGET /mysomethings/someuuid
The status response (when the resource is ready) will include the Location header with the full URL of the resource (for example, https://api.example.com/mysomethings/someuuid )
The combination of both is above, so I have both the resource URL and its id
Some additional thoughts:
An IMO would be impractical to return the resource itself in a status request, because the requested information is a status, not an actual resource.
I also donβt like the ideas suggested in some places to return 202 for status until the resource is ready, and then returned 201 Created, because status codes should convey the status of the request, not the resource (and definitely not another resource, for which the current request requests only status).
Does all this sound right? Any comments are welcome.
source
share