How to create Planner Task with checklist item through Graph API(如何通过 Graph API 创建带有清单项的 Planner 任务)
问题描述
我正在尝试创建一个计划任务,其中包括几个清单项目.清单项目是任务详细信息的一部分,但与描述字段不同,清单项目是具有唯一元素名称的项目列表,如下面的元素示例 14680 和 49286.
I'm trying to create a Planner Task including a couple of checklist items. The checklist items are part of the task details, but unlike the description field, the checklist items are a list of item with a unique element name like the element samples 14680 and 49286 below.
如何通过 API 为任务创建这样的列表?
How can I create such a list for a task through the API?
"checklist": {
"14680": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": true,
"title": "Element 2",
"orderHint": "8586819525[x",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "a275ad83-babe-437e-a62b-e4f4e738fd7b"
}
},
"lastModifiedDateTime": "2018-02-26T14:11:40.2829359Z"
},
"49286": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": false,
"title": "Element 1",
"orderHint": "8586819526571539898P;",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "a275ad83-babe-437e-a62b-e4f4e738fd7b"
}
},
"lastModifiedDateTime": "2018-02-26T14:11:28.3392169Z"
}
},
推荐答案
看起来你至少可以分两步做到这一点:
It looks like you can do that at least by doing it in 2 steps:
首先创建任务,使用
POST/planner/tasks(可用文档 这里)
然后使用 PATCH/planner/tasks/<id>/details (doc)
这个最新的方法在它的主体中有一个 checklist,就像这个例子一样:
This latest method has a checklist in its body like in this example:
PATCH https://graph.microsoft.com/v1.0/planner/tasks/gcrYAaAkgU2EQUvpkNNXLGQAGTtu/details
Content-type: application/json
Content-length: 857
If-Match: W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="
{
"previewType": "noPreview",
"references": {
"http%3A//developer%2Emicrosoft%2Ecom":{
"@odata.type": "microsoft.graph.plannerExternalReference",
"alias": "Documentation",
"previewPriority": " !",
"type": "Other"
},
"https%3A//developer%2Emicrosoft%2Ecom/en-us/graph/graph-explorer":{
"@odata.type": "microsoft.graph.plannerExternalReference",
"previewPriority": " !!",
},
"http%3A//www%2Ebing%2Ecom": null
},
"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",
"isChecked": true,
},
"a93c93c5-10a6-4167-9551-8bafa09967a7": null
}
}
如果您查看 plannerChecklistItems 文档,您会看到清单项的 ID 是客户端生成的 ID:
If you have a look to the plannerChecklistItems documentation, you will see that the checklist item's ID is a client generated ID:
开放类型的属性可以由客户端定义.在这种情况下,客户端应提供 GUID 作为属性,并且它们的值必须是清单项目对象.示例如下所示.删除一个项目检查清单,将属性的值设置为 null.
Properties of an Open Type can be defined by the client. In this case, the client should provide GUIDs as properties and their values must be checklistItem objects. Example is shown below. To remove an item in the checklist, set the value of the property to null.
所以你必须生成自己的 ID,然后你就完成了.
So you have to generate your own IDs and you are done.
这篇关于如何通过 Graph API 创建带有清单项的 Planner 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何通过 Graph API 创建带有清单项的 Planner 任务
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- WPF 模态进度窗口 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
