Full-Stack Web Development with Vue.js and Node

(singke) #1
Introducing REST APIs Chapter 4

201 Created: This represents the successful creation of a resource.
204 No Content: This status code executes the request successfully, but does not
return anything.

4XX codes


The 400 range status codes appear when there is an error on the client side:


400 Bad Request: When the request parameters are not well formatted, or the
syntax is broken, then a 400 status code is returned by the server.
401 Unauthorized: This status code is returned when an unauthorized party tries
to send the API request. This basically checks the authentication part.
403 Forbidden: This is somewhat similar to 401. This checks the authorization of
the party performing the API request. This is basically done when there are
different permission settings for different users performing the API.
404 Not Found: This is returned when the resource that we are trying to perform
some action on is not found by the server in the database.

5XX codes


The 500 range status code informs us that there is something wrong with the execution of


the action performed in the given resource:


500 Internal Server Error: This status code is displayed when the action is not
executed successfully. Like the 200 status code, this is a generic code returned by
the server when something goes wrong.
503 Service Unavailable: This status code is displayed when our server is not
running.
504 Gateway Timeout: This indicates that the request was sent to the server, but
it did not get any response in the given time.
Free download pdf