Tasks: update

Updates the specified task. Try it now or see an example.

Request

HTTP request

PUT https://www.googleapis.com/tasks/v1/lists/tasklist/tasks/task

Parameters

Parameter name Value Description
Path parameters
task string Task identifier.
tasklist string Task list identifier.

Authorization

This request requires authorization with the following scope:

Scope
https://www.googleapis.com/auth/tasks

For more information, see the authentication and authorization page.

Request body

In the request body, supply a Tasks resource.

Response

If successful, this method returns a Tasks resource in the response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

// First retrieve the task to update.
Task task = service.tasks.get("@default", "taskID").execute();
task.setStatus("completed");

Task result = service.tasks.update("@default", task.getId(), task).execute();
// Print the completed date.
System.out.println(result.getCompleted());

PHP

Uses the PHP client library.

/*
 * First retrieve the task to update.
 */
$task = $service->getTasks('@default', 'taskID');
$task->setStatus('completed');

$result = $service->updateTasks($task->getId(), '@default', $task);
/*
 * Print the completed date.
 */
echo $result->getCompleted();

Python

Uses the Python client library.

# First retrieve the task to update.
task = service.tasks().get(tasklist='@default', task='taskID').execute()
task['status'] = 'completed'

result = service.tasks().update(tasklist='@default', task=task['id'], body=task).execute()
# Print the completed date.
print result['completed']

.NET

Uses the .NET client library.

// First retrieve the task to update.
Task task = service.Tasks.Get("@default", "taskID").Fetch();
task.Status = "completed";

Task result = service.Tasks.Update(task, "@default", task.Id).Fetch();
// Print the completed date.
Console.WriteLine(XmlConvert.ToDateTime(result.Completed, XmlDateTimeSerializationMode.Utc));

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.