Sebastian Oswald
Sebastian Oswald

Reputation: 23

Is there an API endpoint to find the drive of a private channel

We are looking into creating teams in our organization with prefilled folder structures 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 structures 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 which creates the private channel?

Upvotes: 2

Views: 1911

Answers (3)

Marc LaFleur
Marc LaFleur

Reputation: 33114

There is a documented navigational property of the Channel resource called filesFolder. From the Graph v1.0 endpoint:

<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:

/v1.0/teams/{teamId}/channels/{channelId}/filesFolder

This will return the Drive associated with a Private Channel:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$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
    }
}

Upvotes: 6

Jimmy
Jimmy

Reputation: 11

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.

Upvotes: 1

AJIXuMuK
AJIXuMuK

Reputation: 17

Currently /filesFolder for Private Channels returns BadGateway

Upvotes: -1

Related Questions