How to complete the challenge GET /api/todos (200) ? filter id greater than

How to issue a GET request on a top level entity endpoint and filter todos by ids greater than a supplied value.

GET /api/todos (200) ? filter id greater than

Issue a GET request on the /api/todos end point with an id filter to return todos with an id greater than a supplied value, requesting the response in JSON format.

  • id>5 means return todos where the id is greater than 5
  • most tools and browsers will encode the > symbol for you when sending the request
  • the response should contain at least one todo
  • the response should be a subset of the current todos, not the full list
  • every returned todo should have an id greater than the threshold
  • the returned todo list should be JSON, so send Accept: application/json if the response is not JSON

Basic Instructions

  • Issue a GET request to end point "/api/todos"
    • https://apichallenges.com/api/todos
  • The request should have an X-CHALLENGER header to track challenge completion
  • The request should have an Accept: application/json header so the API returns todos in JSON format
  • Add an id greater-than filter:
    • https://apichallenges.com/api/todos?id>5
  • The response status code should be 200 because the request is accepted
  • Check that every returned todo has an id greater than 5

Try it now

If you need to check which todo ids are available, use GET /api/todos. See the solution.

GET /api/todos to see the available todo ids

The sample below uses id>5; edit the threshold if your current data needs a different subset.

GET /api/todos?id>5 to return todos with ids greater than 5

Example Request

> GET /api/todos?id>5 HTTP/1.1
> Host: apichallenges.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": 6, "title": "higher id todo", "doneStatus": false, "description": "" }
  ]
}

Lessons Learned

  • Numeric comparison filters such as id>1 depend on ordering and existing fixture data.
  • Greater-than filters are boundary tests: the value equal to the boundary should not be included.
  • The response can be correct even when ids are not contiguous.

Suggested Experiments

  • Compare id>1 with id>2, and inspect which boundary ids disappear.
  • Create a new todo, note its id, then filter above and below that id to test the comparison.
Experiment with this endpoint