Google Tasks API

Tasks: insert

Requires authorization

Creates a new task on the specified task list. Try it now or see an example.

Request

HTTP Request

POST https://www.googleapis.com/tasks/v1/lists/tasklist/tasks

Parameters

Parameter Name Value Description
Required Parameters
tasklist string Task list identifier.
Optional Parameters
parent string Parent task identifier. If the task is created at the top level, this parameter is omitted. Optional.
previous string Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted. Optional.

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

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

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

Task task = new Task();
task.setTitle("New Task");
task.setNotes("Please complete me");
task.setDue(new DateTime(System.currentTimeMillis() + 3600000), 0);

Task result = service.tasks.insert("@default", task).execute();
System.out.println(result.getTitle());

PHP

Uses the PHP client library

$task = new Task();
$task->setTitle('New Task');
$task->setNotes('Please complete me');
$task->setDue(new TaskDateTime('2010-10-15T12:00:00.000Z'));

$result = $service->insertTasks('@default', $task);
echo $result->getId();

Python

Uses the Python client library

task = {
  'title': 'New Task',
  'notes': 'Please complete me',
  'due': '2010-10-15T12:00:00.000Z'
  }

result = service.tasks().insert(tasklist='@default', body=task).execute()
print result['id']

.NET

Uses the .NET client library

Task task = new Task { Title = "New Task"};
task.Notes = "Please complete me";
task.Due = "2010-10-15T12:00:00.000Z";

Task result = service.Tasks.Insert(task, "@default").Fetch();
Console.WriteLine(result.Title);

Try It!

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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.