Skip to main content
blog title image

2 minute read - API Testing API Challenges

How To - POST todos 400

Jan 30, 2021

This post and video shows how to complete the challenge POST /todos (400) to fail to create a todo item in the application due to not passing validation - using Insomnia.

What are the API Challenges?

Our API Challenges Application has a fully functional cloud hosted API, and a set of challenges to work through.

POST /todos (400)

Issue a POST request to create a todo but fail validation on the doneStatus field

  • POST request will create a todo if the details are valid when using the /todos end point
  • 400 is an error code meaning that we supplied invalid details
  • In this case we are asked to make a mistake with the doneStatus field so that it fails validation server side i.e. doneStatus="bob"

Basic Instructions

  • Issue a POST request to end point “/todos”
    • if running locally that would be
      • http://localhost:4567/todos
    • if running in the cloud that would be
  • The request should have an X-CHALLENGER header to track challenge completion
  • The content-type in the message should be application/json because we are sending a JSON payload
  • The Payload should have an error in the doneStatus. A valid doneStatus is true or false so if we send in a String like "bob" it should fail validation.
        "title": "create new todo",
        "doneStatus": "bob",
        "description": "created via insomnia"
  • The response status code should be 400 because the request is invalid
  • The body of the response will be an error message array with a single message
  "errorMessages": [
    "Failed Validation: doneStatus should be BOOLEAN"

Insomnia Details

> POST /todos HTTP/1.1
> Host:
> User-Agent: insomnia/2020.3.3
> X-CHALLENGER: x-challenger-guid
> Content-Type: application/json
> Accept: */*
> Content-Length: 116

|     {
|       "title": "create new todo",
|       "doneStatus": "bob",
|       "description": "created via insomnia"
|     }
< HTTP/1.1 400 Bad Request
< Connection: close
< Date: Thu, 27 Aug 2020 14:23:12 GMT
< Content-Type: application/json
< X-Challenger: x-challenger-guid
< Server: Jetty(9.4.z-SNAPSHOT)
< Via: 1.1 vegur

Returned body:

  "errorMessages": [
    "Failed Validation: doneStatus should be BOOLEAN"

Overview Video

Patreon ad free version

Learn More and Start Testing