命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
警告
Outlook 任务 API 已于 2022 年 8 月 20 日弃用并停止返回数据。 请改用 “To Do API ”。
更改 Outlook 任务的可写属性。
completedDateTime 属性可以通过完成操作设置,也可以由 PATCH 操作显式设置。 如果使用 PATCH 设置 completedDateTime,请确保同时将 状态 设置为 completed
。
默认情况下,此操作 (,POST、GET 和 完成 任务操作) 以 UTC 返回与日期相关的属性。 你可以使用 Prefer: outlook.timezone
标头将响应中的所有与日期相关的属性都表示为与 UTC 不同的时区。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
权限类型 |
最低特权权限 |
更高特权权限 |
委派(工作或学校帐户) |
Tasks.ReadWrite |
不可用。 |
委派(个人 Microsoft 帐户) |
Tasks.ReadWrite |
不可用。 |
应用程序 |
不支持。 |
不支持。 |
HTTP 请求
PATCH /me/outlook/tasks/{id}
PATCH /users/{id|userPrincipalName}/outlook/tasks/{id}
名称 |
说明 |
Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
Prefer: outlook.timezone |
指定响应中时间属性的时区,如果未指定此标头,则为 UTC。 可选。 |
请求正文
在请求正文中,提供应更新的相关字段的值。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为了实现最佳性能,不得添加未变化的现有值。
属性 |
类型 |
说明 |
body |
itemBody |
通常包含有关任务的信息的任务正文。 请注意,仅支持 HTML 类型。 |
类别 |
String 集合 |
与任务关联的类别。 |
changeKey |
String |
任务的版本。 |
completedDateTime |
dateTimeTimeZone |
在指定时区内完成任务的日期。 |
createdDateTime |
DateTimeOffset |
任务的创建日期和时间。 默认情况下,它采用 UTC 格式。 你可以在请求标头中提供自定义时区。 属性值使用 ISO 8601 格式。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z 。 |
dueDateTime |
dateTimeTimeZone |
要在指定时区内完成任务的日期。 |
hasAttachments |
Boolean |
如果任务包含附件,则设置为 true。 |
importance |
string |
事件的重要性。 可取值为:low 、normal 、high 。 |
isReminderOn |
Boolean |
如果设置警报以提醒用户有任务,则设置为 true。 |
lastModifiedDateTime |
DateTimeOffset |
上次修改任务的日期和时间。 默认情况下,它采用 UTC 格式。 你可以在请求标头中提供自定义时区。 属性值使用 ISO 8601 格式,并始终处于 UTC 时间。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z 。 |
Owner |
String |
任务创建者的姓名。 |
parentFolderId |
String |
任务的父文件夹的唯一标识符。 |
定期 |
patternedRecurrence |
任务的定期模式。 |
reminderDateTime |
dateTimeTimeZone |
提醒警报发出任务发生提醒的日期和时间。 |
敏感度 |
string |
指示任务的隐私级别。 可取值为:normal 、personal 、private 、confidential 。 |
startDateTime |
dateTimeTimeZone |
要在指定时区内开始执行任务的日期。 |
状态 |
string |
指示任务的状态或进度。 可取值为:notStarted 、inProgress 、completed 、waitingOnOthers 、deferred 。 |
主题 |
String |
任务的简要说明或标题。 |
响应
如果成功,此方法在响应正文中返回响应 200 OK
代码和更新的 outlookTask 对象。
示例
请求
以下示例修改 dueDateTime 属性,并使用 Prefer: outlook.timezone
标头指定在东部标准时间 (EST) 响应中表示日期相关的属性。
PATCH https://graph.microsoft.com/beta/me/outlook/tasks/AAMkADA1MTHgwAAA=
Prefer: outlook.timezone="Eastern Standard Time"
Content-type: application/json
{
"dueDateTime": {
"dateTime": "2016-05-06T16:00:00",
"timeZone": "Eastern Standard Time"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OutlookTask
{
DueDateTime = new DateTimeTimeZone
{
DateTime = "2016-05-06T16: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.Outlook.Tasks["{outlookTask-id}"].PatchAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Eastern Standard Time\"");
});
mgc-beta users outlook tasks patch --user-id {user-id} --outlook-task-id {outlookTask-id} --body '{\
"dueDateTime": {\
"dateTime": "2016-05-06T16:00:00",\
"timeZone": "Eastern Standard Time"\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "outlook.timezone=\"Eastern Standard Time\"")
configuration := &graphusers.OutlookTasksItemRequestBuilderPatchRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewOutlookTask()
dueDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2016-05-06T16: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().Outlook().Tasks().ByOutlookTaskId("outlookTask-id").Patch(context.Background(), requestBody, configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OutlookTask outlookTask = new OutlookTask();
DateTimeTimeZone dueDateTime = new DateTimeTimeZone();
dueDateTime.setDateTime("2016-05-06T16:00:00");
dueDateTime.setTimeZone("Eastern Standard Time");
outlookTask.setDueDateTime(dueDateTime);
OutlookTask result = graphClient.me().outlook().tasks().byOutlookTaskId("{outlookTask-id}").patch(outlookTask, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Eastern Standard Time\"");
});
const options = {
authProvider,
};
const client = Client.init(options);
const outlookTask = {
dueDateTime: {
dateTime: '2016-05-06T16:00:00',
timeZone: 'Eastern Standard Time'
}
};
await client.api('/me/outlook/tasks/AAMkADA1MTHgwAAA=')
.version('beta')
.update(outlookTask);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Outlook\Tasks\Item\OutlookTaskItemRequestBuilderPatchRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\OutlookTask;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OutlookTask();
$dueDateTime = new DateTimeTimeZone();
$dueDateTime->setDateTime('2016-05-06T16:00:00');
$dueDateTime->setTimeZone('Eastern Standard Time');
$requestBody->setDueDateTime($dueDateTime);
$requestConfiguration = new OutlookTaskItemRequestBuilderPatchRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Eastern Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->outlook()->tasks()->byOutlookTaskId('outlookTask-id')->patch($requestBody, $requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Users
$params = @{
dueDateTime = @{
dateTime = "2016-05-06T16:00:00"
timeZone = "Eastern Standard Time"
}
}
# A UPN can also be used as -UserId.
Update-MgBetaUserOutlookTask -UserId $userId -OutlookTaskId $outlookTaskId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.outlook.tasks.item.outlook_task_item_request_builder import OutlookTaskItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.outlook_task import OutlookTask
from msgraph_beta.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 = OutlookTask(
due_date_time = DateTimeTimeZone(
date_time = "2016-05-06T16:00:00",
time_zone = "Eastern Standard Time",
),
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "outlook.timezone=\"Eastern Standard Time\"")
result = await graph_client.me.outlook.tasks.by_outlook_task_id('outlookTask-id').patch(request_body, request_configuration = request_configuration)
响应
以下示例显示了相应的响应。 注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "AAMkADA1MTHgwAAA=",
"createdDateTime": "2016-04-22T18:19:18.9526004-04:00",
"lastModifiedDateTime": "2016-04-22T18:38:20.5541528-04:00",
"changeKey": "1/KC9Vmu40G3DwB6Lgs7MAAAIW9XXg==",
"categories": [
],
"assignedTo": null,
"body": {
"contentType": "text",
"content": ""
},
"completedDateTime": null,
"dueDateTime": {
"dateTime": "2016-05-06T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
},
"hasAttachments":false,
"importance": "normal",
"isReminderOn": false,
"owner": "Administrator",
"parentFolderId": "AQMkADA1MTIBEgAAAA==",
"recurrence": null,
"reminderDateTime": null,
"sensitivity": "normal",
"startDateTime": {
"dateTime": "2016-05-03T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
},
"status": "notStarted",
"subject": "Shop for children's weekend"
}