This post and video shows how to complete the challenge POST /todos (201)
to create a todo item in the application 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 (201)
Issue a
POST
request to successfully create a todo
POST
request will make changes to the system201
means an item created- We are using this request to create a todo item
- Perform a
GET
first to see what the format of the message is - Add a
Content-Type
ofapplication/json
to tell the server what format the message body is
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
https://apichallenges.herokuapp.com/todos
- if running locally that would be
- The request should have an
X-CHALLENGER
header to track challenge completion - Use the format for the todo which you see in the
GET
response - Do not include an ‘id’ in the request because that is added automatically by the system
- The response status code should be
201
because the todo is created - IF you get a different response code, check the body of the message because you made have made a typo. Read the error message in the response to guide you.
Insomnia Details
> POST /todos HTTP/1.1
> Host: apichallenges.herokuapp.com
> User-Agent: insomnia/2020.3.3
> X-CHALLENGER: x-challenger-guid
> Content-Type: application/json
> Accept: */*
> Content-Length: 108
| {
| "title": "create todo process payroll",
| "doneStatus": true,
| "description": ""
| }
< HTTP/1.1 201 Created
< Connection: close
< Date: Tue, 31 Aug 2021 16:20:40 GMT
< Content-Type: application/json
< Location: todos/453
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: *
< X-Challenger: x-challenger-guid
< Server: Jetty(9.4.z-SNAPSHOT)
< Via: 1.1 vegur