How to complete the challenge POST /api/todos (422)

Issue a POST request to /api/todos with syntactically valid JSON that fails todo validation.

For this challenge, send doneStatus as a string rather than a boolean:

{
  "title": "create new todo",
  "doneStatus": "bob",
  "description": "created via API Challenges"
}

The response should be 422 Unprocessable Content because the request body can be parsed, but the todo data is not valid.

{
  "errorMessages": [
    "Failed Validation: doneStatus should be BOOLEAN"
  ]
}

Remember to include your X-CHALLENGER header so the challenge is tracked.

Try it now

POST /api/todos with invalid doneStatus to trigger 422

Lessons Learned

  • doneStatus must be a boolean value, not a string or arbitrary token.
  • Type validation errors are different from missing-field and length errors.
  • 422 Unprocessable Content can describe semantically invalid data even when JSON syntax is correct.

Suggested Experiments

  • Send "doneStatus":"true" and then "doneStatus":true to compare string versus boolean handling.
  • Omit doneStatus entirely and see whether the defaulting behavior differs from invalid type handling.
Experiment with this endpoint