21. HTTP Codes.
HTTP response codes are concise responses that are super helpful while working with APIs. These are mainly demarcated as follows:
- 1XX - Informational
- 2XX - Success
- 3XX - Redirection
- 4XX - Client Error
- 5XX - Server Error
Some famous ones:
- 200 OK: Basically server giving a hi-fi. All went good.
- 201 Created: It means the data you wanted to put up on the server was sucessfully put.
- 204 No Content: Let's say you want to delete some data. The request was succesful but the server doesn't have any content to send back to the client. In that case we have 204.
- 400 Bad Request: Server doesn't understand the request sent by the client.
- 401 Unauthorized: Means we are missing right credentials, no authentication.
- 403 Forbidden: We have the authentication but no autherization.
- 404 Not Found: We requested a file that doesnt exist.
- 429 Too Many Requests
- 500 Internal Server Error
- 502 Bad Gateway: It is a issue between servers, for eg between proxies and application servers. It is a communication error.
- 503 Service Unavailable: Server is down basically.
- 301 Moved Permanently: It forwards the request to a permanent new address.
- 302 Found: It forwards the request to a temporary new address.
BONUS: Check out what HTTP Code 418 stands for!
Knowledge credits: ByteByteGo.