How to complete the challenge GET /todos (200) ? _sortBy descending
How to issue a GET request on a top level entity endpoint and sort the returned todos in descending order.
GET /todos (200) ? _sortBy descending
Issue a GET request on the
/todosend point with a query parameter to sort todos descending by a field.
_sortByis the URL parameter used to sort collection results- prefix a field with
-to sort descending - for example,
_sortBy=-idsorts the todos from highest id to lowest id - use a field that exists on a todo, such as
id,title,doneStatus, ordescription
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
_sortBy=-idas a URL parameter:https://apichallenges.eviltester.com/todos?_sortBy=-id
- The response status code should be
200because the request is accepted - Check that the returned todos are ordered by
idfrom highest to lowest
Try it now
Example Request
> GET /todos?_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": "highest id first",
"doneStatus": false,
"description": ""
},
{
"id": 9,
"title": "then the next id",
"doneStatus": true,
"description": ""
}
]
}