Graph API: ContentUrl of apps in Microsoft Teams Channel

496 views Asked by At

I am trying to fetch tabs in a Microsoft Teams channel using Graph API. I can see that the contentUrl of NoteBook, Forms, Stream applications does not point to backend SharePoint URL but to application-specific URL. e.g.

ContentURL for Forms is: "contentUrl": "https://forms.office.com/Pages/TeamsDesignPage.aspx?Host=Teams&lang={locale}&groupId={groupId}&tid={tid}&teamsTheme={theme}&upn={upn}&fragment=FormId%3DudjZfPy8PU-0duIp2_KYZNPLlXpeZPZDmWARuiVR2atURDRMQkNSQU1KTFpWNk5CUkVXNE9aMExTUiQlQCN0PWcu",

ContentURl for Notebook is of the form: https://www.onenote.com/teams/TabContent?notebookSource=New&notebookSelfUrl=https%3A%2F%2Fwww.onenote.com%2Fapi%2Fv1.0%2FmyOrganization%2Fgroups%2F7a95cbd3-645e-43f6-9960-11ba2551d9ab%2Fnotes%2Fnotebooks%2F1-6dc4ac26-d65a-4a73-9452-115f850ae7a8&oneNoteWebUrl= ......

Can someone let me know how these application-specific URLs are mapped to backend SharePoint URLs? E.g. I know OneNote is stored in SharePoint but if I have to get the location of OneNote in SharePoint using ContentURL there doesn't seem to be any easy mapping. Please let me know if anyone has any idea about this.

1

There are 1 answers

2
Shweta On

Microsoft Teams uses SharePoint online to store the files for a Team. Each channel in a Team is a folder in the ‘Documents’ library in the SharePoint site collection for the Team.

Sometimes it is necessary to access the underlying SharePoint object that represents the Channel folder in SharePoint to perform specific SharePoint operations.

You can get the SharePoint url of the Team by accessing the Graph API at https://graph.microsoft.com/v1.0/groups/{TeamId}/sites/root/webUrl

Renamed channels stay with the original foldername so you cannot rely on the name of the channel to construct a Url to the channel folder in SharePoint. If the channel has never been renamed the following would work but this would not work for renamed channels or private channels {TeamWebUrl}/Shared Documents/{ChannelName}

Thankfully, new channel properties have been added under the Beta endpoint of the Graph API to give us the underlying SharePoint Url for a channel in Teams.

enter image description here

Please refer to this documentation to know more about the usage of API and necessary permissions associated to call this endpoint.