2
votes

We are looking into creating teams in our organization with prefilled folder struktures in the files tab.

For normal channels this is easy, because the files lay in a directory named after the channel in the root sharepoint of the group. So we can do POST requests to the https://graph.microsoft.com/beta/groups/{group-id}/drive/items/root/children endpoint and create the folders for the channels. The answer from the endpoint contains the ID of the new folders and we can move forward creating the folder struktures for the channels using this id.

Private channels however are located outside the groups sharepoint.

The question is, is there a possibility to get the root of the drive with the information provided by the https://graph.microsoft.com/beta/teams/{id}/channels POST call wich creates the private channel?

3
Please take a look at Private Channel Sharepoint sites.Meanwhile private channel is in developer preview. - Trinetra-MSFT
@Trinetra-MSFT Is it still in developer preview? According to its uservoice it is fully rolled out to public ring. - Sebastian Oswald

3 Answers

4
votes

There is an undocumented navigational property of the Channel resource called filesFolder. From the Graph Beta $metadata:

<EntityType Name="channel" BaseType="microsoft.graph.entity">
  <Property Name="displayName" Type="Edm.String"/>
  <Property Name="description" Type="Edm.String"/>
  <Property Name="isFavoriteByDefault" Type="Edm.Boolean"/>
  <Property Name="email" Type="Edm.String"/>
  <Property Name="webUrl" Type="Edm.String"/>
  <Property Name="membershipType" Type="microsoft.graph.channelMembershipType"/>
  <NavigationProperty Name="messages" Type="Collection(microsoft.graph.chatMessage)" ContainsTarget="true"/>
  <NavigationProperty Name="chatThreads" Type="Collection(microsoft.graph.chatThread)" ContainsTarget="true"/>
  <NavigationProperty Name="tabs" Type="Collection(microsoft.graph.teamsTab)" ContainsTarget="true"/>
  <NavigationProperty Name="members" Type="Collection(microsoft.graph.conversationMember)" ContainsTarget="true"/>
  <NavigationProperty Name="filesFolder" Type="microsoft.graph.driveItem" ContainsTarget="true"/>
</EntityType>

You can call this using this template:

/beta/teams/{teamId}/channels/{channelId}/filesFolder

This will return the Drive associated with a Private Channel:

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#teams('{teamsId}')/channels('{channelId}')/filesFolder/$entity",
    "id": "{id}",
    "createdDateTime": "0001-01-01T00:00:00Z",
    "lastModifiedDateTime": "2019-11-13T16:49:13Z",
    "name": "Private",
    "webUrl": "https://{tenant}.sharepoint.com/sites/{team}-Private/Shared%20Documents/{channel}",
    "size": 0,
    "parentReference": {
        "driveId": "{driveId}",
        "driveType": "documentLibrary"
    },
    "fileSystemInfo": {
        "createdDateTime": "2019-11-13T16:49:13Z",
        "lastModifiedDateTime": "2019-11-13T16:49:13Z"
    },
    "folder": {
        "childCount": 0
    }
}

Important Disclaimer: Please keep in mind that this is a Beta release and, more importantly, it is completely undocumented. This could change at any time and without warning.

0
votes

Currently /filesFolder for Private Channels returns BadGateway

0
votes

The issue you are having is that the drive and site for the private channel is never generated until you actually visit the channel in the teams app. That one visit will trigger the creation of the drive and site. Im stuck here myself as i cannot trigger a private channel to created the SharePoint site and drive until i actually open the teams app and visit the channel.