Introduction to Status Codes in http protocol

In the development of the Restful API, the Status Codes protocol is used as part of the risk, while in this protocol we have about 2 state codes that are divided into 4 different groups, including:

  1. – Group 1xx: This group of codes only gives information to the client.
  2. – Group 2xx: This group of codes suggest that the client request has been successful.
  3. – Group 3xx: This group of codes indicates that the client must take another action to complete the Ricoost.
  4. – Group 4xx: This group of codes reports of the existence of a client on the client.
  5. – Group 5xx: This group of codes indicates a problem on the server side.

Introduction to the application of some 2xx status state codes

The status code 200 with the OK message provides the message that the intended task has been successfully completed, and it is important to note that a rating of 2 depending on what HTTP method is used can have a different body. Also, if we do not want the content in the body, we should use the status code 2 with the No Content message. In fact, the status code 204 is usually sent in response to a request from Post, Put and Delete.

When created on the server side of a new reservoir, the status code with the Created message should be considered, but if the relevant task does not occur immediately and the server needs more time to complete it, it should be from code 1 Used with Accepted message. In other words, Code 2 indicates that the ricoost is accepted for processing, but the processing process is not completed due to its length (this code is used in an operation of the so -called Asynchronous so that it is available to the server so that ricoists are available to the server. Receive other tips.)

Introduction to Status Codes in http protocol

Introduction to the application of some 3XX status state codes

The Status Code 2, with the Moved Permanently message, indicates that the reserves have been moved to a new location, while the new URI should be mentioned in the Location. The Status Code 307 is also used with the Temporary Redirect message when we want to position the client in another way.

Introduction to the application of some 4XX status state codes

The status code of 400 with the Bad Request message indicates that there is a problem on the client side that this problem can be due to the wrong syntax, invalid parameters in the Ricoost and so on, while the client does not need to be re -created without fixing the problem. Submit your request.

Status Code 401 with Unauthorized Message indicates that the client has an operation on the reproduction that requires a password, but the client does not have such password and the 403 status code is related to the Forbidden message that the Ricoost is correctly sent. But the server refuses to do it because, for example, the client does not have the permanent access to that spiring, and the difference with code 401 is that in code 401, for example, the problem is resolved, but when the status code is resolved. 403, it means that even if the password is inserted, there are no reports needed to access the refund.

One of the most famous status codes belongs to the 4xx Group of 404 Status Code with Not Found, which shows that API cannot find on the side of the rear server with an address from the client.

The position code 405 is also used with the Method Not Allowed message when the client is trying to use an HTP method that is not permitted on the server side. For example, a so-called Read-Only reserves only support the Get and Head methods, and if we use a method such as PUT or Delete, we will encounter code 405.

The position code 406 with the Not Acceptable message shows that the server is not capable of producing the client format inserted in the Accept. For example, if the client has a format request in Application/XML format but the server only provides format in the Application/JSON format, we will encounter a position code 406.

Sometimes the client provides a series of conditions for the server that only if they are met, the Ricoost must be fulfilled, so that if those conditions are not fulfilled, the status code 412 will be sent with the Precondition Failed message.

Introduction to the application of some 5xx status state codes

The status code 500 usually occurs with the Internal Server Error message when the app occurs on the side of the app, indicating that the problem is completely responsible for the server and the client has no fault! Also, the status code 501 with the not implemented message suggests that for any reason the submitted ricoist cannot be completed.

HTTP status codes contains a complete list of all status codes that can be used as a comprehensive reference that, in addition to introducing the status codes, clicks on each of them, explaining their nature.

© 2022 Created with AloApi Team.