Error handling
When we throw an exception because something happened during the execution of our application, we should give more information to our users or consumers about what happened. This is possible by adding describable standard codes, also known as status codes. Using these standard codes in your responses will help you (and your colleagues) to know quickly if something is going wrong in your application. Check the following list to know what are the correct and most common HTTP status codes to use them in your API.
Client request successful
If your application needs to inform the API client that the request was successful, you would usually reply with one of the following HTTP status codes:
- 200 - OK: The request was done successfully
- 201 - Created: Successfully created the URI specified by the client
- 202 - Accepted: Accepted for processing but the server has not finished processing it
- 204 - No Content: Request is complete without any information being sent back in the response