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?
200 OK. 201 Created. 202 Accepted. 203 Non-Authoritative Information. 204 No Content.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With