How to complete the challenge PUT /api/todos body id (200)

Issue a PUT request to /api/todos and include the id of an existing todo in the request body.

This API allows the identifier for a PUT update to come from the payload, so /api/todos can update a specific todo when the body contains an existing id.

Basic Instructions

  • Send PUT /api/todos
  • Add an X-CHALLENGER header to track challenge completion
  • Set Content-Type to application/json
  • Include an id for an existing todo in the JSON payload
  • Include a valid title because this API treats PUT as a replacement update
  • Verify the response status is 200

Example body:

{
  "id": 3,
  "title": "updated using body id",
  "doneStatus": true,
  "description": "updated by PUT /api/todos"
}

Try it now

If you don't know what todos are available then you can check by GET /api/todos. See the solution.

GET /api/todos to see what todos are available now

If you have already deleted all todos, create one using POST /api/todos. See the solution.

POST /api/todos to create a todo item for this challenge
PUT /api/todos with an existing id in the payload

Lessons Learned

  • PUT /api/todos can update when the target id is supplied in the body instead of the URL.
  • Body-identified updates are API-specific and should be documented clearly in tests.
  • The response should confirm which existing todo id was updated.

Suggested Experiments

  • Send the same body to PUT /api/todos twice and confirm the second call does not create a duplicate.
  • Change the body id to a missing value and compare update success with validation failure.
Experiment with this endpoint