How to complete the challenge POST /todos/id (200)
How to use a POST request to successfully update a todo item in the application.
POST /todos/id (200)
Issue a POST request to successfully update a todo
POSTrequest will update a todo if the providedidexists/todos/idend point- e.g.
POST /todos/3for a todo withid==3
- e.g.
200is an success code, in this case it means the todo was updated- The body of the message should be a
jsonorxmlpartial set oftododetails, - and the
jsonorxmlshould be defined in thecontent-typeheader
Basic Instructions
- Issue a
POSTrequest to end point "/todos/id"- where
idis replaced with the id of an existing todo- if you don't know any then a
GET /todoswould show a list of todos, or you couldPOST /todosto create one.
- if you don't know any then a
https://apichallenges.herokuapp.com/todos/id
- where
- The request should have an
X-CHALLENGERheader to track challenge completion - The
content-typein the message should beapplication/jsonbecause we are sending a JSON payload - The Payload should have a partial set of todo details. e.g.
{
"title": "updated title"
}
- The response status code should be
200when all the details are valid. - The body of the response will a JSON showing the full todo details, and your updated values should be present.
{
"id": 49,
"title": "updated title",
"doneStatus": false,
"description": ""
}
NOTE: if you haven't read the documentation and don't know what format to use then issue a GET request for a single entity and the payload format for the POST is likely to be pretty close. You may not be allowed to use all the fields in an update, e.g. the id might throw an error becuase you should not be able to update the id.
Example Request
> POST /todos/49 HTTP/1.1
> Host: apichallenges.herokuapp.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Content-Type: application/json
> Accept: */*
> Content-Length: 32
| {
| "title": "updated title"
| }
Example Response
< HTTP/1.1 200 OK
< Connection: close
< Date: Sat, 06 Feb 2021 12:08:58 GMT
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: *
< X-Challenger: x-challenger-guid
< Server: Jetty(9.4.z-SNAPSHOT)
< Via: 1.1 vegur
Returned body:
{
"id": 49,
"title": "updated title",
"doneStatus": false,
"description": ""
}