You can support this site from as little as $1 a month on Patreon.

The support pays for site hosting and the expansion of this content.

In addition, Patreon Supporters gain access to exclusive online video training courses and ebooks.

Join Now

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 /todos end point with a query parameter to sort todos descending by a field.

  • _sortBy is the URL parameter used to sort collection results
  • prefix a field with - to sort descending
  • for example, _sortBy=-id sorts the todos from highest id to lowest id
  • use a field that exists on a todo, such as id, title, doneStatus, or description

Basic Instructions

  • Issue a GET request to end point "/todos"
    • https://apichallenges.eviltester.com/todos
  • The request should have an X-CHALLENGER header to track challenge completion
  • Add _sortBy=-id as a URL parameter:
    • https://apichallenges.eviltester.com/todos?_sortBy=-id
  • The response status code should be 200 because the request is accepted
  • Check that the returned todos are ordered by id from 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": ""
    }
  ]
}