Tutorial: Update a task

In this tutorial, you learn the operations to call to update a task for a user of the service.

Expect this tutorial to take about 10 minutes to complete.

Before you start

Make sure you’ve completed the Before you start a tutorial topic on the development system you’ll use for the tutorial.

Update a task

Updating a task in the service requires that you use the PATCH method to change the details of the task resource in the service.

To update a task:

  1. Make sure your local service is running, or start it by using this command, if it’s not.

     cd <your-github-workspace>/to-do-service/api
     json-server -w to-do-db-source.json
    
  2. Open the Postman app on your desktop.
  3. In the Postman app, create a new request with these values:
    • METHOD: PATCH
    • URL: Specify the {id} of the task that you want to update.
      • /tasks/{id}
    • Headers:
      • Content-Type: application/json
    • Request body: You can change the values of each property as you’d like, but don’t change the property names.

      This example updates dueDate and warning.

        {
            "dueDate": "2026-08-01T18:00",
            "warning": "50"
        }
      
  4. In the Postman app, choose Send to make the request.
  5. Watch for the response body, which should look something like this for the task id of 1.

     {
         "userId": 1,
         "title": "Grocery shopping",
         "description": "eggs, bacon, gummy bears",
         "dueDate": "2026-08-01T18:00",
         "warning": "50",
         "id": 1
     }
    

After doing this tutorial in Postman, you might like to repeat it in your favorite programming language. To do this, adapt the values from the tutorial to the properties and arguments that the language uses to make REST API calls.