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-CHALLENGERheader to track challenge completion - Set
Content-Typetoapplication/json - Include an
idfor an existing todo in the JSON payload - Include a valid
titlebecause 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/todoscan update when the targetidis 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
idwas updated.
Suggested Experiments
- Send the same body to
PUT /api/todostwice and confirm the second call does not create a duplicate. - Change the body
idto a missing value and compare update success with validation failure.