【问题标题】:Unable to add Teams/SharePoint file attachment in a task to ' Tasks by Planner and To Do '无法将任务中的 Teams/SharePoint 文件附件添加到“Planner 的任务和待办事项”
【发布时间】:2021-04-14 09:56:31
【问题描述】:

我有一个完全构建的 API,它可以将任务创建到 MS Teams 的“Tasks by Planner and To Do”中。

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 1Test Document 2 时,它会分别抛出unknown errorSorry, something went wrong

之后,我手动创建了任务并添加了来自Add Attachment 的附件并将文件的链接粘贴到那里,然后单击文件工作并打开文档。

【问题讨论】:

  • 您能否添加您调用的 API 的完整详细信息以及正文的完整(编辑)示例。目前尚不清楚您调用的是哪个 API 或版本,或者它是 POST 还是 PATCH
  • 您能否说明一下如何获取 Teams/SPO 文件 URL?和天气与否该文件与任务的所有者共享
  • 另请参阅对 (a Flow)[powerusers.microsoft.com/t5/Power-Automate-Community-Blog/… 的引用,该引用在将 SPO 托管文档添加为任务附件之前创建了指向 SPO 托管文档的共享链接;

标签: microsoft-graph-api microsoft-teams microsoft-planner


【解决方案1】:

假设您指的是为 PlannerTask 添加/更新Planner Task Details

提供了一个示例,使用您提到的“团队路径”添加(PATCH)pptx 文件。
请注意,路径必须是(url)编码的。

任务 - plannerTaskDetail references

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"
  }
}

【讨论】:

    猜你喜欢
    • 2021-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 2016-10-08
    • 2015-07-08
    • 2017-10-10
    • 2023-01-21
    相关资源
    最近更新 更多