but I still think that I should raise my question and my thoughts here. What should be the HTTP status code in the REST API to use the GET for the QUERY resource "Not ready yet, try again later"? For example, a client tries to request all local news in the future (!) By making an HTTP GET for this URL: http://example.com/news?city=chicago&date=2099-12-31 so that the server responds?
This is the http status code I reviewed, their definition of rfc and why I am not completely satisfied:
3xx Redirection. Comment Not an option because there is no other redirect link.
503 Service Unavailable: the server is currently unable to process the request due to temporary overload or server maintenance. It is understood that this is a temporary condition that will be mitigated after some delay. If known, the delay length MAY be indicated in the Retry-After header. Comment : retry behavior is desirable, but semantically the situation is not a server error, so all 5xx look weird.
4xx client error. Comment It looks promising. See below.
413 Request Entity Too Large: the server refuses to process the request because the request object is larger than the server is ready or able to process .... If the condition is temporary, the server MUST include a Retry-After header field to indicate that it is temporary and through what time the client MAY try again. Commentary : repeated behavior is required, but the Essence Too large part is somewhat misleading.
417 Expectation Failed: The wait specified in the Expect request header field (see section 14.20) cannot be performed by this server. Comment Therefore, it should be called by the Expect request header, not applicable to my case.
406 Not valid: resource ... not acceptable according to accept headers sent in the request. Comment : therefore, it is called by the Accept request header, not applicable to my case.
409 Conflict: The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user will be able to resolve the conflict and resubmit the request .... Conflicts most often occur in response to a PUT request. Comment This object is close. Although my case is not about PUT and is not really caused by conflict.
404 Not Found: the server did not find anything that matched the Request-URI. Comment Technically, my path to the URL ( http://example.com/news ) Exists; these are the parameters causing the problems. In this case, returning an empty collection instead of 404 is probably more appropriate.
403 Forbidden: the server understood the request, but refuses to fulfill it. Authorization will not help, and the request MUST NOT be repeated. Comment As a rule, is this supposed to be used in any limited resource?
400 Bad Request: the request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request unchanged. Comment In my case this is not true. My server understands the request, its syntax is good, only the value is bad.
2xx Successfully. Comment : If 4xx does not work, how about 2xx? See below.
200 OK. Comment : Good. So what should I include in the response agency? null or [] or {} or {"date": "2099-12-31", "content_list": null} or ... which one is more intuitive? On the other hand, I prefer a way to clearly distinguish between the minor error of "future news" from the more common "all query criteria - this is good, not news on this day."
202 Accepted: The request has been accepted for processing, but processing has not yet been completed. The request may or may not be subsequently applied. Comment Giving us the ability to use 202 in a GET request is acceptable. Then refer to comment 200.
204 No content: the server has completed the request, but it does not need to return the body of the entity. Comment If we can use 204 in a GET request, this is acceptable. I just don't know if it's better than 202 or 200.
Read more about 2xx: Comment . I assume that the entire 2xx answer will most likely be cached. But in my case, if I return the empty body for tomorrow's news, I do not want it to be cached. Well, I explicitly point out that the "no cache" headers should help.