GET all the todos in default format
How to complete the challenge GET /api/todos ANY (200) to successfully GET all the todos in default format.
GET /api/todos ANY (200)
Issue a GET request on the
/api/todosend point with anAcceptheader of*/*to receive results in Default format
GETrequest will receive a response with all the todo items- e.g.
GET /api/todosto get all the todo items
- e.g.
200is a success code, in this case it means the end point exists and the todo items were returnedAcceptmeans that anAcceptheader was added to specify that the todos should be returned in ANY format i.e. the default from the server- add the
X-CHALLENGERheader to track progress
Basic Instructions
- Issue a
GETrequest to end point "/api/todos"- if running locally that endpoint would be
https://apichallenges.com/api/todos
- if running locally that endpoint would be
- The request should have an
Acceptheader specifying ANY format by using a value of*/*, our application defaults to JSON - The request should have an
X-CHALLENGERheader to track challenge completion - The response status code should be
200when all the details are valid. - Check the body of the message has JSON format data, which is the default from the server
- Check the
content-typeheader in the response hasapplication/json
Try it now
GET /api/todos with Accept: */* to request any supported format
Example Request
> GET /api/todos HTTP/1.1
> Host: apichallenges.com
> User-Agent: insomnia/2021.2.2
> X-CHALLENGER: x-challenger-guid
> Accept: */*
Example Response
< HTTP/1.1 200 OK
< Connection: close
< Date: Sat, 29 May 2021 09:06:15 GMT
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: *
< X-Challenger: x-challenger-guid
< Server: Jetty(9.4.z-SNAPSHOT)
< Via: 1.1 vegur
Example Response body:
{
"todos": [
{
"id": 235,
"title": "pay invoices",
"doneStatus": false,
"description": ""
},
{
"id": 239,
"title": "tidy meeting room",
"doneStatus": false,
"description": ""
}
]
}
Overview Video
Lessons Learned
*/*inAcceptsays the client has no format preference, so the server default becomes part of the behavior under test.- A
200 OKresponse with wildcard negotiation still needs aContent-Typecheck because the requested format was deliberately broad. - This challenge is useful for finding the API fallback representation before writing stricter
Accepttests.
Suggested Experiments
- Send
Accept: */*, then remove theAcceptheader entirely and compare the selectedContent-Type. - Send
Accept: image/pngand confirm the API reports negotiation failure instead of silently returningJSON.