Files
What you'll learn
- Read a status code by its class: 2xx success, 3xx go elsewhere, 4xx the client's mistake, 5xx the server's
- Choose between 400, 404, 405, 409 and 422 by what went wrong
- Redirect permanently with 308 and a Location, keeping the method, and answer 405 with an Allow header
Press Run tests to start the app. Its log appears here.Graded endpoints
The body cannot be parsed: the client's mistake, so 400, and a message instead of the server's 500
Valid JSON, but not a valid cat: 422, the request was understood and cannot be processed
Only spaces is not a name either
The age is checked after the name
A number, but not a whole one
Nothing is wrong with the request itself; it conflicts with what is stored: 409
Every refusal above left the collection as it was
201 with a Location, as before
The path exists and the method does not apply to it: 405, and Allow says what does
The same answer for every method GET and POST do not handle
308 Permanent Redirect: moved for good, and the client must repeat the same method at the new URL
The id carries over, and a POST stays a POST, which a 301 would not promise
Milo, where the redirect points
404, unchanged