Namespace: microsoft.graph
Update the properties of a todoTask object.
This API is available in the following national cloud deployments.
| Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
| ✅ |
✅ |
✅ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
| Permission type |
Least privileged permissions |
Higher privileged permissions |
| Delegated (work or school account) |
Tasks.ReadWrite |
Not available. |
| Delegated (personal Microsoft account) |
Tasks.ReadWrite |
Not available. |
| Application |
Not supported. |
Not supported. |
HTTP request
PATCH /me/todo/lists/{todoTaskListId}/tasks/{taskId}
PATCH /users/{id|userPrincipalName}/todo/lists/{todoTaskListId}/tasks/{taskId}
Request body
In the request body, supply a JSON representation of the todoTask object.
The following table lists the properties that are required when you create the todoTask.
| Property |
Type |
Description |
| id |
String |
The unique identifier of the task. Inherited from entity |
| body |
itemBody |
The task body that typically contains information about the task. Note that only HTML type is supported. |
| categories |
String collection |
The categories associated with the task. Each category corresponds to the displayName property of an outlookCategory that the user has defined. |
| completedDateTime |
dateTimeTimeZone |
The date in the specified time zone that the task was finished. |
| dueDateTime |
dateTimeTimeZone |
The date in the specified time zone that the task is to be finished. |
| importance |
importance |
The importance of the event. The possible values are: low, normal, high. |
| isReminderOn |
Boolean |
Set to true if an alert is set to remind the user of the task. |
| recurrence |
patternedRecurrence |
The recurrence pattern for the task. |
| reminderDateTime |
dateTimeTimeZone |
The date and time for a reminder alert of the task to occur. |
| startDateTime |
dateTimeTimeZone |
The date in the specified time zone at which the task is scheduled to start. |
| status |
taskStatus |
Indicates state or progress of the task. The possible values are: notStarted, inProgress, completed, waitingOnOthers, deferred. |
| title |
String |
A brief description of the task. |
| createdDateTime |
DateTimeOffset |
The date and time when the task was created. By default, it is in UTC. You can provide a custom time zone in the request header. |
| lastModifiedDateTime |
DateTimeOffset |
The date and time when the task was last modified. By default, it is in UTC. You can provide a custom time zone in the request header. |
| bodyLastModifiedDateTime |
DateTimeOffset |
The date and time when the task body was last modified. By default, it is in UTC. You can provide a custom time zone in the request header. |
Response
If successful, this method returns a 200 OK response code and an updated todoTask object in the response body.
Examples
Request
PATCH https://graph.microsoft.com/v1.0/me/todo/lists/AAMkADA1MTHgwAAA=/tasks/721a35e2-35e2-721a-e235-1a72e2351a72
Content-Type: application/json
{
"dueDateTime":{
"dateTime":"2020-07-25T16:00:00",
"timeZone":"Eastern Standard Time"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new TodoTask
{
DueDateTime = new DateTimeTimeZone
{
DateTime = "2020-07-25T16:00:00",
TimeZone = "Eastern Standard Time",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Todo.Lists["{todoTaskList-id}"].Tasks["{todoTask-id}"].PatchAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewTodoTask()
dueDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2020-07-25T16:00:00"
dueDateTime.SetDateTime(&dateTime)
timeZone := "Eastern Standard Time"
dueDateTime.SetTimeZone(&timeZone)
requestBody.SetDueDateTime(dueDateTime)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
tasks, err := graphClient.Me().Todo().Lists().ByTodoTaskListId("todoTaskList-id").Tasks().ByTodoTaskId("todoTask-id").Patch(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TodoTask todoTask = new TodoTask();
DateTimeTimeZone dueDateTime = new DateTimeTimeZone();
dueDateTime.setDateTime("2020-07-25T16:00:00");
dueDateTime.setTimeZone("Eastern Standard Time");
todoTask.setDueDateTime(dueDateTime);
TodoTask result = graphClient.me().todo().lists().byTodoTaskListId("{todoTaskList-id}").tasks().byTodoTaskId("{todoTask-id}").patch(todoTask);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const todoTask = {
dueDateTime: {
dateTime: '2020-07-25T16:00:00',
timeZone: 'Eastern Standard Time'
}
};
await client.api('/me/todo/lists/AAMkADA1MTHgwAAA=/tasks/721a35e2-35e2-721a-e235-1a72e2351a72')
.update(todoTask);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\TodoTask;
use Microsoft\Graph\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TodoTask();
$dueDateTime = new DateTimeTimeZone();
$dueDateTime->setDateTime('2020-07-25T16:00:00');
$dueDateTime->setTimeZone('Eastern Standard Time');
$requestBody->setDueDateTime($dueDateTime);
$result = $graphServiceClient->me()->todo()->lists()->byTodoTaskListId('todoTaskList-id')->tasks()->byTodoTaskId('todoTask-id')->patch($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Users
$params = @{
dueDateTime = @{
dateTime = "2020-07-25T16:00:00"
timeZone = "Eastern Standard Time"
}
}
# A UPN can also be used as -UserId.
Update-MgUserTodoListTask -UserId $userId -TodoTaskListId $todoTaskListId -TodoTaskId $todoTaskId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.todo_task import TodoTask
from msgraph.generated.models.date_time_time_zone import DateTimeTimeZone
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TodoTask(
due_date_time = DateTimeTimeZone(
date_time = "2020-07-25T16:00:00",
time_zone = "Eastern Standard Time",
),
)
result = await graph_client.me.todo.lists.by_todo_task_list_id('todoTaskList-id').tasks.by_todo_task_id('todoTask-id').patch(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#tasks/$entity",
"@odata.etag": "W/\"s8/ERWT3WEeFpBGD0bDgAA+TWq9g==\"",
"importance": "low",
"isReminderOn": false,
"status": "notStarted",
"title": "Shop for dinner",
"createdDateTime": "2020-07-22T10:39:03.7937971Z",
"lastModifiedDateTime": "2020-07-22T12:02:10.8835421Z",
"categories": [],
"id": "721a35e2-35e2-721a-e235-1a72e2351a72",
"body": {
"content": "",
"contentType": "text"
},
"dueDateTime": {
"dateTime": "2020-08-25T04:00:00.0000000",
"timeZone": "UTC"
}
}