How to complete the challenge GET /api/todo 404.

How to solve challenge GET todo 404 by issuing a GET request on a non-existent endpoint and receive a 404 status code response.

GET /api/todo (404)

Issue a GET request on the /api/todo end point should 404 because nouns should be plural

  • This will show you an error status code 404
  • 404 means 'not found' i.e. we tried to access something that does not exist
  • REST API Endpoints are usually plural e.g. /api/todos we would not normally expect an API to respond to both /api/todos and /api/todo

Basic Instructions

  • Issue a GET request to end point "/api/todo"
    • https://apichallenges.com/api/todo
  • The request should have an X-CHALLENGER header
  • The response status code should be 404

Try it now

GET /api/todo to trigger 404 for the singular endpoint

Example Request

> GET /api/todo HTTP/1.1
> Host: apichallenges.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Accept: */*

Example Response

< HTTP/1.1 404 Not Found
< Connection: close
< Date: Thu, 27 Aug 2020 13:46:19 GMT
< X-Challenger: x-challenger-guid
< Server: Jetty(9.4.z-SNAPSHOT)
< Via: 1.1 vegur

Overview Video

Watch on YouTube: "Solution to GET non-existent todo challenge"

Patreon ad free version

Lessons Learned

  • /api/todo is the wrong route, so 404 Not Found here tests URL design and plural resource naming.
  • This is not a missing todo id; the route itself does not match the API contract.
  • Path typos can look like data problems unless you compare the documented URL.

Suggested Experiments

  • Change only /api/todo to /api/todos and confirm the same GET style reaches a valid collection route.
  • Try /api/todos/999999 after /api/todo and compare route-not-found with resource-not-found behavior.
Experiment with this endpoint