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 ascending

How to issue a GET request on a top level entity endpoint and sort the returned todos in ascending order.

GET /todos (200) ? _sortBy ascending

Issue a GET request on the /todos end point with a query parameter to sort todos ascending by a field.

  • GET request will return items from the /todos end point
  • 200 is the success code meaning the request was accepted
  • _sortBy is the URL parameter used to sort collection results
  • use a todo field name as the value, e.g. _sortBy=title
  • a plain field name sorts ascending
  • +field also means ascending, but using just the field name avoids client URL encoding surprises

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=title as a URL parameter:
    • https://apichallenges.eviltester.com/todos?_sortBy=title
  • The response status code should be 200 because the request is accepted
  • Check that the returned todos are ordered by title from A to Z

Try it now

Example Request

> GET /todos?_sortBy=title 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": 4,
      "title": "file paperwork",
      "doneStatus": false,
      "description": ""
    },
    {
      "id": 2,
      "title": "process payroll",
      "doneStatus": true,
      "description": ""
    }
  ]
}