How to complete the challenge PUT /api/todos/{id} no amend id (422)
Issue a PUT request to an existing todo and include an id in the body that does not match the id in the URL.
The response should be 422 Unprocessable Content because the API does not allow the primary key to be amended through the request body.
Look for the validation message containing:
Can not amend id from
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/{id} with a mismatched body id to trigger 422
Lessons Learned
- A body
idthat conflicts with the URLidis rejected to protect resource identity. PUTupdates should not allow clients to rename or move a resource accidentally.- Identity mismatch tests are most useful when all other fields are valid.
Suggested Experiments
- Send a matching body
id, then change only the bodyidand compare200 OKwith422 Unprocessable Content. - Change only the URL
idwhile keeping the bodyidfixed to see the same mismatch from the other side.