Http status code (Status Codes)

VII status code (the Status Codes)
* server returns a status code to the user and prompts, some of the common are the following (in brackets is the HTTP status code corresponding verb).
200 OK - [GET]: the server returns the data requested by the user successfully, the operation is idempotent (Idempotent).
201 CREATED - [POST / PUT / PATCH]: new or modified user data successfully.
202 Accepted - [*]: represents a request has been queued into the background (asynchronous task)
204 NO CONTENT - [DELETE]: Delete user data successfully.
400 INVALID REQUEST - [POST / PUT / PATCH]: request issued by a user mistake, the server does not create or modify the operation data, the operation is idempotent.
401 Unauthorized - [*]: indicates that the user does not have permission (Token, username, password error).
403 Forbidden - [*] indicates that the user is authorized (and 401 relative error), but access is prohibited.
404 NOT FOUND - [*]: user issues a request for recording is not present, the server is not operated, the operation is idempotent.
406 Not Acceptable - [GET]: the format requested by the user is not available (such as JSON format requested by the user, but only the XML format).
410 Gone - [GET]: user request resources are permanently removed, and will not be obtained.
422 Unprocesable entity - [POST / PUT / PATCH] When an object is created, a verification error occurs.
500 INTERNAL SERVER ERROR - [*] : server error occurs, the user will be unable to determine whether the request is sent successfully.
* A complete list of status codes can be found here.
Eight, Error Handling (Error Handling)
* If the status code 4xx, it should return an error message to the user. In general, the error information will be returned as the key name as a key to the error message.
{
    Error: "Invalid the API Key"
}

Guess you like

Origin www.cnblogs.com/94cool/p/11038146.html