更新 plannerTask
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 plannertask 对象的属性。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
❌
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
Tasks.ReadWrite
Group.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
Tasks.ReadWrite.All
不可用。
HTTP 请求
PATCH /planner/tasks/{id}
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
If-Match
要更新 plannerTask 的最后一个已知 ETag 值。 必填。
请求正文
在请求正文中, 仅 提供要更新的属性的值。 请求正文中未包含的现有属性会保留其以前的值,或者根据对其他属性值的更改重新计算。
下表指定可更新的属性。
属性
类型
说明
appliedCategories
plannerAppliedCategories
指定应用Planner任务的类别。 有关可能的值,请参阅 应用的类别 。
assigneePriority
String
用于在列表视图中对此类项进行排序的提示。 格式在 Planner 中使用顺序提示中 定义。
assignments
plannerAssignments
分配到任务的用户集合。
bucketId
String
此任务所属的存储桶 ID。 存储桶需要位于任务所在的计划中。 此值长度为 28 个字符,区分大小写。
格式验证 在服务上完成。
conversationThreadId
字符串
任务上的会话的线程 ID,是在组中创建的会话线程对象的 ID。
dueDateTime
DateTimeOffset
任务截止的日期和时间。 时间戳类型表示采用 ISO 8601 格式的日期和时间信息,始终采用 UTC 时区。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z
isOnMyDay
布尔值
指示是否在 MyDay 视图中显示此任务。 如果 true
为 ,则显示任务。
orderHint
String
用于在列表视图中对此类项进行排序的提示。 格式的定义如下所述。
percentComplete
Int32
任务完成百分比。
100
设置为 时,任务被视为已完成。
planId
String
任务所属的计划 ID。
priority
Int32
任务优先级。 值的有效范围介于 0
和 10
(包含) 之间,递增值 (0
优先级最高且 10
优先级) 最低。 目前,Planner将值0
和 1
解释为“紧急”,2
并将 3
4
和 解释为“important”、5
、 6
和 7
“medium”,以及 8
、 9
和 10
“low”。 目前,Planner设置“紧急”、“3
重要5
”、“中”和9
“低”的值1
。
recurrence
plannerTaskRecurrence
任务的重复周期(如果已定义)。 可选。
startDateTime
DateTimeOffset
任务开始的日期和时间。 时间戳类型表示采用 ISO 8601 格式的日期和时间信息,始终采用 UTC 时区。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z
。
title
String
任务的标题。
注意
对于复制到Planner的项目任务,只能更新 percentComplete 属性。
响应
如果成功,此方法将 204 No Content
返回响应代码和空内容。 如果请求使用首选项指定 Prefer
标头 return=representation
,则此方法在响应正文中返回响应 200 OK
代码和更新的 plannerTask 对象。
此方法可以返回任何 HTTP 状态代码 。 应用应为此方法处理的最常见错误是 400、403、404、409 和 412 响应。 有关这些错误的详细信息,请参阅常见Planner错误条件 。
示例
请求
以下示例显示了一个请求。
PATCH https://graph.microsoft.com/beta/planner/tasks/01gzSlKkIUSUl6DF_EilrmQAKDhh
Content-type: application/json
Prefer: return=representation
If-Match: W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="
{
"assignments": {
"fbab97d0-4932-4511-b675-204639209557": {
"@odata.type": "#microsoft.graph.plannerAssignment",
"orderHint": "N9917 U2883!"
}
},
"appliedCategories": {
"category3": true,
"category4": false
},
"recurrence": {
"schedule": {
"pattern": {
"type": "daily",
"interval": 3
},
"patternStartDateTime": "2022-02-22T02:10:33Z"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new PlannerTask
{
Assignments = new PlannerAssignments
{
AdditionalData = new Dictionary<string, object>
{
{
"fbab97d0-4932-4511-b675-204639209557" , new PlannerAssignment
{
OdataType = "#microsoft.graph.plannerAssignment",
OrderHint = "N9917 U2883!",
}
},
},
},
AppliedCategories = new PlannerAppliedCategories
{
AdditionalData = new Dictionary<string, object>
{
{
"category3" , true
},
{
"category4" , false
},
},
},
Recurrence = new PlannerTaskRecurrence
{
Schedule = new PlannerRecurrenceSchedule
{
Pattern = new RecurrencePattern
{
Type = RecurrencePatternType.Daily,
Interval = 3,
},
PatternStartDateTime = DateTimeOffset.Parse("2022-02-22T02:10:33Z"),
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Planner.Tasks["{plannerTask-id}"].PatchAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "return=representation");
requestConfiguration.Headers.Add("If-Match", "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"");
});
mgc-beta planner tasks patch --planner-task-id {plannerTask-id} --if-match "W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="" --body '{\
"assignments": {\
"fbab97d0-4932-4511-b675-204639209557": {\
"@odata.type": "#microsoft.graph.plannerAssignment",\
"orderHint": "N9917 U2883!"\
}\
},\
"appliedCategories": {\
"category3": true,\
"category4": false\
},\
"recurrence": {\
"schedule": {\
"pattern": {\
"type": "daily",\
"interval": 3\
},\
"patternStartDateTime": "2022-02-22T02:10:33Z"\
}\
}\
}\
'
// 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"
graphplanner "github.com/microsoftgraph/msgraph-beta-sdk-go/planner"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "return=representation")
headers.Add("If-Match", "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"")
configuration := &graphplanner.TasksItemRequestBuilderPatchRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewPlannerTask()
assignments := graphmodels.NewPlannerAssignments()
additionalData := map[string]interface{}{
"fbab97d0-4932-4511-b675-204639209557" := graphmodels.NewPlannerAssignment()
orderHint := "N9917 U2883!"
"fbab97d0-4932-4511-b675-204639209557".SetOrderHint(&orderHint)
assignments.Set"fbab97d0-4932-4511-b675-204639209557"("fbab97d0-4932-4511-b675-204639209557")
}
assignments.SetAdditionalData(additionalData)
requestBody.SetAssignments(assignments)
appliedCategories := graphmodels.NewPlannerAppliedCategories()
additionalData := map[string]interface{}{
category3 := true
appliedCategories.SetCategory3(&category3)
category4 := false
appliedCategories.SetCategory4(&category4)
}
appliedCategories.SetAdditionalData(additionalData)
requestBody.SetAppliedCategories(appliedCategories)
recurrence := graphmodels.NewPlannerTaskRecurrence()
schedule := graphmodels.NewPlannerRecurrenceSchedule()
pattern := graphmodels.NewRecurrencePattern()
type := graphmodels.DAILY_RECURRENCEPATTERNTYPE
pattern.SetType(&type)
interval := int32(3)
pattern.SetInterval(&interval)
schedule.SetPattern(pattern)
patternStartDateTime , err := time.Parse(time.RFC3339, "2022-02-22T02:10:33Z")
schedule.SetPatternStartDateTime(&patternStartDateTime)
recurrence.SetSchedule(schedule)
requestBody.SetRecurrence(recurrence)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
tasks, err := graphClient.Planner().Tasks().ByPlannerTaskId("plannerTask-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);
PlannerTask plannerTask = new PlannerTask();
PlannerAssignments assignments = new PlannerAssignments();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
PlannerAssignment fbab97d049324511B675204639209557 = new PlannerAssignment();
fbab97d049324511B675204639209557.setOdataType("#microsoft.graph.plannerAssignment");
fbab97d049324511B675204639209557.setOrderHint("N9917 U2883!");
additionalData.put("fbab97d0-4932-4511-b675-204639209557", fbab97d049324511B675204639209557);
assignments.setAdditionalData(additionalData);
plannerTask.setAssignments(assignments);
PlannerAppliedCategories appliedCategories = new PlannerAppliedCategories();
HashMap<String, Object> additionalData1 = new HashMap<String, Object>();
additionalData1.put("category3", true);
additionalData1.put("category4", false);
appliedCategories.setAdditionalData(additionalData1);
plannerTask.setAppliedCategories(appliedCategories);
PlannerTaskRecurrence recurrence = new PlannerTaskRecurrence();
PlannerRecurrenceSchedule schedule = new PlannerRecurrenceSchedule();
RecurrencePattern pattern = new RecurrencePattern();
pattern.setType(RecurrencePatternType.Daily);
pattern.setInterval(3);
schedule.setPattern(pattern);
OffsetDateTime patternStartDateTime = OffsetDateTime.parse("2022-02-22T02:10:33Z");
schedule.setPatternStartDateTime(patternStartDateTime);
recurrence.setSchedule(schedule);
plannerTask.setRecurrence(recurrence);
PlannerTask result = graphClient.planner().tasks().byPlannerTaskId("{plannerTask-id}").patch(plannerTask, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "return=representation");
requestConfiguration.headers.add("If-Match", "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"");
});
const options = {
authProvider,
};
const client = Client.init(options);
const plannerTask = {
assignments: {
'fbab97d0-4932-4511-b675-204639209557': {
'@odata.type': '#microsoft.graph.plannerAssignment',
orderHint: 'N9917 U2883!'
}
},
appliedCategories: {
category3: true,
category4: false
},
recurrence: {
schedule: {
pattern: {
type: 'daily',
interval: 3
},
patternStartDateTime: '2022-02-22T02:10:33Z'
}
}
};
await client.api('/planner/tasks/01gzSlKkIUSUl6DF_EilrmQAKDhh')
.version('beta')
.update(plannerTask);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Planner\Tasks\Item\PlannerTaskItemRequestBuilderPatchRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\PlannerTask;
use Microsoft\Graph\Beta\Generated\Models\PlannerAssignments;
use Microsoft\Graph\Beta\Generated\Models\PlannerAssignment;
use Microsoft\Graph\Beta\Generated\Models\PlannerAppliedCategories;
use Microsoft\Graph\Beta\Generated\Models\PlannerTaskRecurrence;
use Microsoft\Graph\Beta\Generated\Models\PlannerRecurrenceSchedule;
use Microsoft\Graph\Beta\Generated\Models\RecurrencePattern;
use Microsoft\Graph\Beta\Generated\Models\RecurrencePatternType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new PlannerTask();
$assignments = new PlannerAssignments();
$additionalData = [
'fbab97d0-4932-4511-b675-204639209557' => [
'@odata.type' => '#microsoft.graph.plannerAssignment',
'orderHint' => 'N9917 U2883!',
],
];
$assignments->setAdditionalData($additionalData);
$requestBody->setAssignments($assignments);
$appliedCategories = new PlannerAppliedCategories();
$additionalData = [
'category3' => true,
'category4' => false,
];
$appliedCategories->setAdditionalData($additionalData);
$requestBody->setAppliedCategories($appliedCategories);
$recurrence = new PlannerTaskRecurrence();
$recurrenceSchedule = new PlannerRecurrenceSchedule();
$recurrenceSchedulePattern = new RecurrencePattern();
$recurrenceSchedulePattern->setType(new RecurrencePatternType('daily'));
$recurrenceSchedulePattern->setInterval(3);
$recurrenceSchedule->setPattern($recurrenceSchedulePattern);
$recurrenceSchedule->setPatternStartDateTime(new \DateTime('2022-02-22T02:10:33Z'));
$recurrence->setSchedule($recurrenceSchedule);
$requestBody->setRecurrence($recurrence);
$requestConfiguration = new PlannerTaskItemRequestBuilderPatchRequestConfiguration();
$headers = [
'Prefer' => 'return=representation',
'If-Match' => 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->planner()->tasks()->byPlannerTaskId('plannerTask-id')->patch($requestBody, $requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Planner
$params = @{
assignments = @{
"fbab97d0-4932-4511-b675-204639209557" = @{
"@odata.type" = "#microsoft.graph.plannerAssignment"
orderHint = "N9917 U2883!"
}
}
appliedCategories = @{
category3 = $true
category4 = $false
}
recurrence = @{
schedule = @{
pattern = @{
type = "daily"
interval = 3
}
patternStartDateTime = [System.DateTime]::Parse("2022-02-22T02:10:33Z")
}
}
}
Update-MgBetaPlannerTask -PlannerTaskId $plannerTaskId -BodyParameter $params -IfMatch W/'"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="'
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.planner.tasks.item.planner_task_item_request_builder import PlannerTaskItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.planner_task import PlannerTask
from msgraph_beta.generated.models.planner_assignments import PlannerAssignments
from msgraph_beta.generated.models.planner_assignment import PlannerAssignment
from msgraph_beta.generated.models.planner_applied_categories import PlannerAppliedCategories
from msgraph_beta.generated.models.planner_task_recurrence import PlannerTaskRecurrence
from msgraph_beta.generated.models.planner_recurrence_schedule import PlannerRecurrenceSchedule
from msgraph_beta.generated.models.recurrence_pattern import RecurrencePattern
from msgraph_beta.generated.models.recurrence_pattern_type import RecurrencePatternType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = PlannerTask(
assignments = PlannerAssignments(
additional_data = {
"fbab97d0-4932-4511-b675-204639209557" : {
"@odata_type" : "#microsoft.graph.plannerAssignment",
"order_hint" : "N9917 U2883!",
},
}
),
applied_categories = PlannerAppliedCategories(
additional_data = {
"category3" : True,
"category4" : False,
}
),
recurrence = PlannerTaskRecurrence(
schedule = PlannerRecurrenceSchedule(
pattern = RecurrencePattern(
type = RecurrencePatternType.Daily,
interval = 3,
),
pattern_start_date_time = "2022-02-22T02:10:33Z",
),
),
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "return=representation")
request_configuration.headers.add("If-Match", "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"")
result = await graph_client.planner.tasks.by_planner_task_id('plannerTask-id').patch(request_body, request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"createdBy": {
"user": {
"id": "6463a5ce-2119-4198-9f2a-628761df4a62"
}
},
"planId": "xqQg5FS2LkCp935s-FIFm2QAFkHM",
"bucketId": "gcrYAaAkgU2EQUvpkNNXLGQAGTtu",
"title": "title-value",
"orderHint": "9223370609546166567W",
"assigneePriority": "90057581\"",
"createdDateTime": "2015-03-24T18:36:49.2407981Z",
"assignments": {
"6463a5ce-2119-4198-9f2a-628761df4a62": {
"@odata.type": "#microsoft.graph.plannerAssignment",
"assignedBy": {
"user": {
"id": "6463a5ce-2119-4198-9f2a-628761df4a62"
}
},
"assignedDateTime": "2015-03-25T18:38:21.956Z",
"orderHint": "N9917"
},
"fbab97d0-4932-4511-b675-204639209557": {
"@odata.type": "#microsoft.graph.plannerAssignment",
"assignedBy": {
"user": {
"id": "1e9955d2-6acd-45bf-86d3-b546fdc795eb"
}
},
"assignedDateTime": "2017-04-24T22:40:44.5665917",
"orderHint": "RWk1"
},
"aaa27244-1db4-476a-a5cb-004607466324": {
"@odata.type": "#microsoft.graph.plannerAssignment",
"assignedBy": {
"user": {
"id": "6463a5ce-2119-4198-9f2a-628761df4a62"
}
},
"assignedDateTime": "2015-03-25T18:38:21.956Z",
"orderHint": "U2883"
}
},
"appliedCategories": {
"category3": true,
"category5": true,
"category6": true
},
"id": "01gzSlKkIUSUl6DF_EilrmQAKDhh",
"recurrence": {
"@odata.type": "#microsoft.graph.plannerTaskRecurrence",
"seriesId": "qOqWwPLt4U-LIsWV5ByUuA",
"occurrenceId": 1,
"previousInSeriesTaskId": null,
"nextInSeriesTaskId": null,
"schedule": {
"@odata.type": "#microsoft.graph.plannerRecurrenceSchedule",
"pattern": {
"odata.type": "#microsoft.graph.recurrencePattern",
"type": "daily",
"interval": 3,
"firstDayOfWeek": "sunday",
"dayOfMonth": 0,
"daysOfWeek": [],
"index": "first",
"month": 0
},
"patternStartDateTime": "2022-02-22T02:10:33Z",
"nextOccurrenceDateTime": "2022-02-25T02:10:33Z"
},
"recurrenceStartDateTime": "2022-02-22T02:10:33Z"
}
}