Every web request gets a status code in reply. Reading these codes quickly tells you whether the problem is in the request, the server or the code behind it.
The ones you will meet most
- 200 OK: the request worked.
- 201 Created: a new item was saved, usually after a POST.
- 400 Bad Request: the data sent was wrong or incomplete.
- 401 and 403: the user is not signed in (401) or not allowed (403).
- 404 Not Found: the address does not exist.
- 500 Internal Server Error: the code on the server failed. Check the logs.
A simple habit
When an API call fails, look at the status code first, then the response body. A 400 points to the data you sent. A 500 points to the server code.
Build a small API to see these codes in action: What is a REST API? is a good start. Our Python course covers APIs in practice. Book a free demo class, and ask a counsellor for batch details.
