本文介绍了如何通过 Graph API 创建带有清单项的 Planner Task的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含几个清单项目的 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"
        }
    },

推荐答案

看起来你至少可以通过 2 个步骤做到这一点:

It looks like you can do that at least by doing it in 2 steps:

  • 创建任务 1st,使用 POST/planner/tasks(文档可用 这里)

然后使用 PATCH/planner/tasks//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 作为属性,并且它们的值必须是checklistItem 对象.示例如下所示.删除项目清单,将属性的值设置为 null.

因此您必须生成自己的 ID,然后就完成了.

So you have to generate your own IDs and you are done.

这篇关于如何通过 Graph API 创建带有清单项的 Planner Task的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 15:13