How to complete the challenge GET /todos (200) ? filter
How to issue a GET request on a top level entity endpoint and use a query filter to receive a subset of data.
GET /todos (200) ? filter
Issue a GET request on the
/todosend point with a query filter to get only todos which are 'done'. There must exist both 'done' and 'not done' todos, to pass this challenge.
GETrequest will return all items from the/todosend point200is the success code meaning the request was accepted?means we need to add a URL Parameterfiltermeans it will filter based on an attribute. In this case we are asked to filter on those which are 'done'. And this is represented by thedoneStatusi.e.doneStatus=true- We are using this request to
GETa filter list of todo items - Perform a
GETfirst to see what the format of the message is - Add a URL parameter to the request to repeat the
GETand filter the list of todos e.g./todos?doneStatus=true
Basic Instructions
- Issue a
GETrequest to end point "/todos"https://apichallenges.com/todos
- The request should have an
X-CHALLENGERheader to track challenge completion - Look at the returned format for todos
{
"id": 41,
"title": "create todo process payroll",
"doneStatus": true,
"description": ""
},
- we want to use the
doneStatusattribute as a URL parameter - if you don't see any todos in the list with a
"doneStatus": truethen you will need to issue aPOSTrequest to create or amend a todo item. e.g. challenge POST todos 201 - Issue a
GETrequest with a URL parameter/todos?doneStatus=true - The response status code should be
200because the request is accepted - If you get a different response code, check the URL or headers of the message because you made have made a typo.
- If you don't see any todos returned then you may need to create one e.g. challenge POST todos 201
Try it now
If you need fixture data, create one done todo and one not-done todo first. See the solution.
POST /todos to create a done todo fixture
POST /todos to create a not-done comparison todo
Filter for done todos:
GET /todos?doneStatus=true to return only done todos
Example Request
> GET /todos?doneStatus=true HTTP/1.1
> Host: apichallenges.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Accept: application/json
Example Response
< HTTP/1.1 200 OK
< Connection: close
< Date: Tue, 15 Dec 2020 17:32:12 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
Returned body:
{
"todos": [
{
"id": 41,
"title": "create todo process payroll",
"doneStatus": true,
"description": ""
}
]
}