Front-end friends sometimes see the status code of 4XX in the browser console when connecting the interface. Some friends will directly take screenshots and send them to the background staff, saying: “There is something wrong with this interface”. 😂 In fact, the problem of 4xx belongs to the client problem.

So let’s look at the usual 400, 401, 403, 404, 412, 417 explanations

1, 400 Bad Request, see the diagram

When the client requests the server, the server finds that the content of the request has a problem and can’t give you the relative result. It needs to return status code 400 to tell the client that the content of your request has a problem and needs to be modified and sent again.

The browser will treat 200 ok out of 400. No error handling occurs.

2. 401 Unauthorized (not verified) : See the figure

When a client requests a server resource, but the server says: “If you want to get this resource, you need your identity authentication, please follow my authentication method (BASIC and DIGEST, these two authentication methods will return wwW-authenticate to the client, for more details, please see BASIC authentication and DIGEST Authentication).” And return the header field with wwW-authenticate: ‘verification method’ and status code 401.

After the client gets the authentication method in the wwW-Authenticate in the response header, the authentication window will be displayed on the client. After the user completes the input, the client will send the request again with the authentication information.

403 Forbidden Forbidden Access deniedWhen the client accesses the server, the server says to the client: ‘You have been denied access, I will not tell you why, if you want to know, look at the response entity’.

After the client gets the 403, it can display the reason for the error based on the massage of the response entity


4, 404 Not Found

When the client accesses the server, the server says to the client: ‘Sorry, I don’t have the resource you want, or I don’t want to give you the resource.’

5, 412 Precomdition Failed



This is related to if-match, if-ranges, and Ranges. You can rest assured that this status code will not appear in the case of class one.

When a client requests a server resource, it carries an if-match value in the header field of the request. This value is the ETag value that the server previously returned with the client resource. When the server sees an if-match, it compares it to the ETag of the server resource. If it finds an if-match, it compares it to the ETag of the server resource. ==ETag, the server returns status code 412.

The client sees the status code 412 and sends the request again

417 Expectation Failed




The client asks the server if you can give me the resource I want. The server looks at its own resources, thinks about such a precious resource, and says: ‘Don’t think about the resource you expect, I can’t give it to you’.