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
/todosend point with a query parameter to sort todos ascending by a field.
GETrequest will return items from the/todosend point200is the success code meaning the request was accepted_sortByis 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
+fieldalso means ascending, but using just the field name avoids client URL encoding surprises
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=titleas a URL parameter:https://apichallenges.eviltester.com/todos?_sortBy=title
- The response status code should be
200because the request is accepted - Check that the returned todos are ordered by
titlefrom 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": ""
}
]
}