Reputation: 21761
I have an API that accepts requests. The requests are long running, so I return a 202 Accepted
and say 'if you want to know the status, check out http://blah/jobstatus/1234'
What return code should http://blah/jobstatus/1234 return? (the status is quick and easy to provide)
Should it return a 200
with a resource describing the status of the job, or should it return another 202
if the job is still running and then a 200
(or 201
)?
I think it should return a 200
because the user is asking for a resource that represent the current status of the job.
This page covers the you should return a 202
for long running stuff, but doesn't cover what the status endpoint should return.
Upvotes: 0
Views: 639
Reputation: 57259
When returning a
202
containing a status endpoint, what status code should that endpoint return?
Status codes belong to the transporting documents over a network domain.
GET /jobstatus/1234
That's a request that asks for a current representation of the /jobstatus/1234
resource. If the server has a current representation for that resource, it should return that representation, a 200 OK status code, and any appropriate meta data...
Just like every other page on the web.
The fact that /jobstatus/1234
is a resource that describes an ongoing process doesn't make it special in any way. It is still just a document, and it should be responding according to the standard.
Upvotes: 1
Reputation: 29157
It seems to me the status address should simply return whatever is expected (Running/Complete or whatever it is you provide). Using different http status codes with this in addition to the response provided seems redundant to me if you are already providing that information.
As you say "(the status is quick and easy to provide)", so why bother with anything other than 200? That seems to be the simplest thing that would work without going overboard.
Upvotes: 1
Reputation: 99553
The status endpoint itself should just return 200 OK
.
This is because this endpoint describes information about the operation, not the operation itself. And fetching this information completes immediately, not eventually.
Upvotes: 3