我正在尝试创建一个带有清单的新任务。
我阅读了in this article,需要分两个步骤进行操作;
1.创建任务
2. PATCH
任务,添加清单项目。
尝试PATCH
添加任务时,它不会添加任何内容。它只能编辑现有的值,比如“称号”。我无法找到任何方式或文档,以PUT
的细节,或在初始创建它们POST
创建任务时。
有人知道该怎么做吗?
POST-创建新任务:
URI: https://graph.microsoft.com/v1.0/planner/tasks
Content-Type : application/json
RAW:
{
"planId": "{plan_id}",
"bucketId": "{bucket_id}",
"title": "Here is a task",
"checklist": {
"95e27074-6c4a-447a-aa24-9d718a0b86fa":{
"@odata.type": "microsoft.graph.plannerChecklistItem",
"title": "Task details",
"ischecked": true
},
"d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff":{
"@odata.type": "microsoft.graph.plannerChecklistItem"
}
}
}
响应:身体,201成功:
BODY:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity",
"@odata.etag": "W/\"…ETag…\"",
"planId": "{plan_id}",
"bucketId": "{bucket_id}",
"title": "Here is a task",
"orderHint": "8586523326629295130",
"assigneePriority": "",
"percentComplete": 0,
"startDateTime": null,
"createdDateTime": "2019-02-04T09:57:02.5480677Z",
"dueDateTime": null,
"hasDescription": false,
"previewType": "automatic",
"completedDateTime": null,
"completedBy": null,
"referenceCount": 0,
"checklistItemCount": 0,
"activeChecklistItemCount": 0,
"conversationThreadId": null,
"id": "{task_id}",
"createdBy": {
"user": {
"displayName": null,
"id": "{UID}"
}
},
"appliedCategories": {},
"assignments": {}
}
而且试图把checklist
为details
块中的块,并得到完全相同的结果。
"details": {
"checklist": { … }
}
PATCH - 更新现有任务:
URI: https://graph.microsoft.com/v1.0/planner/tasks/{task_id}
HEADERS:
If-Match : W/"…ETag…"
Content-type : application/json
RAW:
{
"title": "New title",
"checklist": {
"95e27074-6c4a-447a-aa24-9d718a0b86fa":{
"@odata.type": "microsoft.graph.plannerChecklistItem",
"title": "Update task details",
"ischecked": true
},
"d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff":{
"@odata.type": "microsoft.graph.plannerChecklistItem"
}
}
}
响应:空,204次成功。标题被改变,但没有新的清单项。
答案 0 :(得分:1)
您无法在创建任务的同时更新详细信息。 plannerTask
和plannerTaskDetails
是不同的对象。此外,details
property of a plannerTask
is read-only。
您需要先create a plannerTask
,然后再update it's associated plannerTaskDetails
。