How to complete the challenge HEAD /api/todos (200)
How to issue a HEAD request and see the results of a GET request without the body of the response, this can be useful for checking the existence of an item when automating.
HEAD /api/todos (200)
Issue a HEAD request on the
/api/todosend point
HEADrequest is basically aGETbut doesn't return the body- Use it to 'ping' an end point and see if it exists, or to check the Headers are working correctly
- Usually returns a 200 (if it exists) or a 404 (if it doesn't exist)
Basic Instructions
- Issue a HEAD request to end point "/api/todos"
https://apichallenges.com/api/todos
- The request should have an
X-CHALLENGERheader to track challenge completion - The response status code should be
200because the end point exists - Compare the response with the response from
GET /api/todos
Try it now
HEAD /api/todos to read response headers without a body
Example Request
> HEAD /api/todos HTTP/1.1
> Host: apichallenges.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Accept: */*
Example Response
< HTTP/1.1 200 OK
< Connection: keep-alive
< Date: Thu, 27 Aug 2020 14:09:19 GMT
< Content-Type: application/json
< X-Challenger: x-challenger-guid
< Server: Jetty(9.4.z-SNAPSHOT)
< Via: 1.1 vegur
Overview Video
Lessons Learned
HEAD /api/todosreturns metadata for the collection without sending the response body.- Headers from
HEADshould help clients decide whether a laterGETis worth making. - A passing
HEADtest should assert the body is empty, not merely ignored.
Suggested Experiments
- Send
HEAD /api/todosandGET /api/todosback to back and compare status plus response headers. - Change the
Acceptheader onHEADand see whether content negotiation affectsContent-Type.