Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST API 202 versus 204

I'm dealing with a REST API and have this question, when a request is scheduled for further processing we should return 202, when a request has no response body we should return 204. What should we do when a request will be in processing further, but has no response body either?

like image 967
maurorodrigues Avatar asked Jan 02 '13 14:01

maurorodrigues


People also ask

What does the response code 202 and 204 mean?

200 OK. 201 Created. 202 Accepted. 203 Non-Authoritative Information. 204 No Content.

Should Put return 200 or 204?

200 OK - This is the most appropriate code for most use-cases. 204 No Content - A proper code for updates that don't return data to the client, for example when just saving a currently edited document. 202 Accepted - If the update is done asynchronous, this code can be used.

When should I use HTTP Status 202?

HTTP Status 202 indicates that the request has been accepted for processing, but the processing has not been completed. This status code is useful when the actual operation is asynchronous in nature.

When should 204 be used?

HTTP Status 204 (No Content) indicates that the server has successfully fulfilled the request and that there is no content to send in the response payload body.


1 Answers

That would be a 202. There is no response body after the processing is complete (and successful).

If there is no way for it to fail, or the client doesn't care about failure, and the client doesn't care when the action is complete, then 204 would be appropriate as there's no point in delaying it.

like image 75
Potatoswatter Avatar answered Oct 10 '22 03:10

Potatoswatter