0
votes

I have a fully built API, that creates tasks into MS Teams "Tasks by Planner and To Do".

MS actual graph API used POST https://graph.microsoft.com/v1.0/planner/tasks

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

Hitting the above API creates a task in the planner as seen below

enter image description here

So, here is an issue - when I try to click on link it took me to the browser and opens up google which is fine. Now, when I click on Test Document 1 or Test Document 2 it throws an unknown error and Sorry, something went wrong respectively.

After that, I created the task manually and adding the attachments from Add Attachment and paste the links to the file there, then click the files works and opens up the documents.

1
Can you please add the full details of the API that you call and the complete ( redacted) sample of the body. currently it is not clear which API or Version you call or wether it is an POST or a PATCHJos Verlinde
Can you also clarify how you aquire the Teams/SPO file URLs ? and weather or not the file is shared with the owner of the taskJos Verlinde
Also see this reference to (a Flow)[powerusers.microsoft.com/t5/Power-Automate-Community-Blog/… that crates a Sharing-Link to a SPO hosted document before adding it as a Task Attachment;Jos Verlinde

1 Answers

0
votes

Assuming you are referring to adding / updating the Planner Task Details for a PlannerTask;

there is a sample provided of adding (PATCH) a pptx file using a 'teams path' as you referred to it.
Note that the path must be (url)encoded.

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