如何通过 Graph API 创建带有清单项的 Planner 任务

How to create Planner Task with checklist item through Graph API(如何通过 Graph API 创建带有清单项的 Planner 任务)
本文介绍了如何通过 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 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)