How to complete the challenge GET /todos (200) ? _sortBy multiple
How to issue a GET request on a top level entity endpoint and sort the returned todos by more than one field.
GET /todos (200) ? _sortBy multiple
Issue a GET request on the
/todosend point with a query parameter to sort todos by multiple fields.
_sortByis the URL parameter used to sort collection results- separate multiple sort fields with commas
- a plain field name sorts ascending
- prefix a field with
-to sort descending - for example,
_sortBy=doneStatus,-idsorts bydoneStatusascending, then byiddescending within each done status
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=doneStatus,-idas a URL parameter:https://apichallenges.eviltester.com/todos?_sortBy=doneStatus,-id
- The response status code should be
200because the request is accepted - Check that todos are grouped by
doneStatus, and within each group the ids are descending
Try it now
Example Request
> GET /todos?_sortBy=doneStatus,-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": 8,
"title": "not done with higher id",
"doneStatus": false,
"description": ""
},
{
"id": 3,
"title": "not done with lower id",
"doneStatus": false,
"description": ""
},
{
"id": 9,
"title": "done with higher id",
"doneStatus": true,
"description": ""
}
]
}