How to complete the challenge GET /todos (200) ?_sortBy&_limit&_offset
How to issue a GET request on a top level entity endpoint and combine sorting with pagination.
GET /todos (200) ?_sortBy&_limit&_offset
Issue a GET request on the
/todosend point with sorting and pagination parameters.
_sortBy=-idsorts todos byidfrom highest to lowest_limit=5asks for 5 returned todos_offset=5skips 5 todos after sorting- sorting is applied before pagination
- if your current session has fewer todos after the offset, the response will contain fewer todos
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=-id,_limit=5, and_offset=5as URL parameters:https://apichallenges.eviltester.com/todos?_sortBy=-id&_limit=5&_offset=5
- The response status code should be
200because the request is accepted - Check that the response body contains no more than 5 todos and the ids are still descending
Try it now
Example Request
> GET /todos?_sortBy=-id&_limit=5&_offset=5 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": 15, "title": "fifth page item", "doneStatus": false, "description": "" },
{ "id": 14, "title": "sixth page item", "doneStatus": false, "description": "" },
{ "id": 13, "title": "seventh page item", "doneStatus": false, "description": "" },
{ "id": 12, "title": "eighth page item", "doneStatus": false, "description": "" },
{ "id": 11, "title": "ninth page item", "doneStatus": false, "description": "" }
]
}