How to complete the challenge GET /todos (200) ? filter and _sortBy
How to issue a GET request on a top level entity endpoint, filter the returned todos, and sort the filtered results.
GET /todos (200) ? filter and _sortBy
Issue a GET request on the
/todosend point with a query filter and a query parameter to sort the filtered todos.
- todo fields can be used as URL parameters to filter collection results
_sortByis the URL parameter used to sort collection results- prefix a sort field with
-to sort descending - for example,
doneStatus=false&_sortBy=-idreturns only not done todos, sorted byidfrom highest to lowest
Basic Instructions
- Issue a
GETrequest to end point "/todos"https://apichallenges.eviltester.com/todos
- The request should have an
X-CHALLENGERheader to track challenge completion - Add
doneStatus=falseand_sortBy=-idas URL parameters:https://apichallenges.eviltester.com/todos?doneStatus=false&_sortBy=-id
- The response status code should be
200because the request is accepted - Check that all returned todos have
doneStatusset tofalse, and that the ids are descending
Try it now
Example Request
> GET /todos?doneStatus=false&_sortBy=-id HTTP/1.1
> Host: apichallenges.eviltester.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Accept: application/json
Example Response
< HTTP/1.1 200 OK
< Connection: close
< Content-Type: application/json
< X-Challenger: x-challenger-guid
Returned body:
{
"todos": [
{
"id": 10,
"title": "not done with highest id",
"doneStatus": false,
"description": ""
},
{
"id": 3,
"title": "not done with lower id",
"doneStatus": false,
"description": ""
}
]
}