Response Codes: 401, 404, 405 and an Empty List

How the server reports problems: 401 without logging in, 405 for a method that is not allowed, 404 when deleting a product that does not exist, and 200 OK with an empty list.

About the product

Alex, QA Team Lead

Hi! We’ve seen how everything works when it goes well. But a tester also checks how the server reports problems: every response has a status code for that. Today we’ll go through the most common codes using examples from the BB Food admin panel.

Quick reference

Code groups

The first digit of the code tells what happened. 2xx is success, 4xx is a client error (a wrong or impossible request), 5xx is a server error.

401 Unauthorized

The server doesn’t know who sent the request: the client is not logged in or sent invalid login data. A tester checks that the data didn’t change and the user sees a clear message.

405 Method Not Allowed

The address exists, but this method is not allowed for it.

404 Not Found

There is no such resource: for example, the product is already deleted. The server changes nothing and says the thing asked for isn’t there.

200 OK and an empty list

An empty result is not an error. The request succeeded, there is just no suitable data. A tester checks code 200, an empty list in the body and a clear hint for the user.