microsoft-graph-api - 无法将任务中的 Teams/SharePoint 文件附件添加到“Planner 的任务和待办事项”
问题描述
我有一个完全构建的 API,可以将任务创建到 MS Teams“计划者和待办事项的任务”中。
使用的 MS 实际图形 API POST
https://graph.microsoft.com/v1.0/planner/tasks
示例 API:
{
"routeId": "7fcxxxxx-xxxx-xxxx-xxxx-5d35838xxxxx",
"userId": "77cxxxxx-xxxx-xxxx-xxxx-5f09858xxxxx",
"tenantId": "dcdxxxxx-xxxx-xxxx-xxxx-31002a1xxxxx",
"title": "Task: Add you task title",
"hospitalAssignment": null,
"percentComplete": 0,
"createdTimestamp": "2021-04-20T01:51:49Z",
"startDateTimestamp": "2021-04-20T18:10:15Z",
"dueDate": "2021-11-20T11:47:33.000Z",
"Notes": "Add some useful notes here",
"checklistItems": [
{
"title": "itema"
},
{
"title": "itemb"
}
],
"attachments": [
{
"url": "https://www.google.com",
"alias": "link"
},
{
"url": "https://teams.microsoft.com/file/....",
"alias": "Test Document 1"
},
{
"url": "https://random.sharepoint.com/sites/...",
"alias": "Test Document 2"
},
],
"comments": "null,",
"priority": null
}
点击上面的 API 在计划器中创建一个任务,如下所示
所以,这里有一个问题——当我尝试点击它时,link
它把我带到了浏览器并打开,google
这很好。现在,当我点击Test Document 1
或Test Document 2
它分别抛出一个unknown error
和Sorry, something went wrong
。
之后,我手动创建了任务并从中添加附件Add Attachment
并将链接粘贴到那里,然后单击文件工作并打开文档。
解决方案
假设您指的是为 PlannerTask 添加/更新Planner Task Details;
提供了一个示例,使用您提到的“团队路径”添加(PATCH)pptx 文件。
请注意,路径必须是(url)编码的。
任务 - plannerTaskDetail <参考
https://docs.microsoft.com/en-us/graph/api/resources/plannerexternalreferences?view=graph-rest-1.0
{
"https%3A//contoso%2Esharepoint%2Ecom/teams/agile/documents/AnnualReport%2Epptx":
{
"@odata.type": "microsoft.graph.externalReference", // required in PATCH requests to edit the references on a task
"alias": "Agile Team Annual Report",
"lastModifiedBy": {
"user": {
"id": "ebf3b108-5234-4e22-b93d-656d7dae5874"
}
},
"lastModifiedDateTime": "2015-09-21T17:45:12.039Z",
"previewPriority": "0009005756397228702",
"type": "PowerPoint"
}
}
推荐阅读
- elasticsearch - grafana elasticsearch 数据源配置
- android - 从 Xamarin Android 中的资源文件获取 StreamReader
- javascript - 如何将 JS 函数打印成 HTML?
- python - 如何拆分我从网页中提取的数据并将每一行附加到列表中?
- flutter - inavlid 参数/异常被小部件库捕获
- php - 根据条件逻辑更改变量的值
- arrays - 反转数组后,数组 b[i] 正在打印一些地址,但不是反转的值。请告诉我代码有什么问题
- laravel - 使用资源时 Laravel 转换模型值
- arduino - 如何使用 ILI9341 正确绘制框架?阿杜诺
- python - 如何使用 Python 在 Plotly Dash 中实现下拉菜单?