I am implementing a REST API which involves creating a object on the server. The object creation involves multiple steps and may take a while. I do not want the user to wait on it. I simply return a 202 response with a unique request id for the client request and start some threads on the server to create the object. The client is supposed to check back to see whether the request is completed or not, in the future. The flow goes like this:
- The client POSTs the object.
- The server responds with a 202 Accepted code with a Location header
/my-app/<reqId> - The client does a GET on
/my-app/<reqId>
Now at the third step, these things might happen:
- Object creation is still in progress(client should check again after sometime).
- Some Error occured.
- Object is successfully created.
Now what http code should my API /my-app/<reqId> respond for the above three scenarios?