I'm developing a RESTful API in which http://server/thingyapi/thingyblob/1234
returns the file (aka "blob") associated with thingy #1234 to download. But it may be that the request is made at a time the file does not exist in the server but most definitely will be available at a later time. There's a batch process in the server that generates all the blobs for all the thingies. Thingy 1234 already exists and its data, other than the blob, is already available. The server hasn't got to generating thingy 1234's blob yet.
I don't want to return 404; that's for thingies that do not exist. This is a thingy that exists, but its blob hasn't been generated yet. Kinda like a YouTube video that's "processing." I don't think redirection codes would be proper either; there's no "other" URL to try.
What's the correct HTTP status code to return in such a case?
Another option:
503 - Service Unavailable
.501 - Not Implemented
Exactly like how it sounds. A feature that is not yet implemented, but implies future availability.
Here is a link to a summary of 5xx errors.
The URL doesn't correspond to a request for a thingy.
http://server/thingyapi/thingyblob/1234
The client is requesting a thingyblob, which doesn't exist. If it existed, you would give it to them.
404.
Since your resource is not ready, you probably know when (approximately) it will be available and when client may retry his request. This means you might want to utilize Retry-After header. This header is valid with 503 (Service Unavailable), which means whole site is down for maintenance, and 3xx (Redirection) responses.
In my opinion 302 (Found) with Retry-After header would be the best option, but I am not sure if Location field of response header can be equal to request url. It's circular redirect, anyway.
The "problem", such as it is, is on the server side: the client has made a well formed request, but the server can not satisfy it. So I'm inclined to a "Server Error", 5xx status code. Quoth the standard:
Note
Of the available codes, I'd say 503, "Service Unavailable" was the best fit:
Note:
Retry-After
value. You could provide as the value the estimated completion time of the next execution of the batch process, or the execution interval of the batch process.Defining your own 5xx status code (591, for example), although permitted, would have the wrong semantics:
Clients would treat your own status code as 500, "Internal Server Error", which (as I discussed above) would not be right.
I think that 423 - Locked can be used for this purpose: