1
votes

I'm trying to add a SharePoint Library tab to a Microsoft Team Channel programmatically through the Microsoft Graph. Here is the payload I'm sending through the Graph Explorer POST

{
    "teamsAppId": "com.microsoft.teamspace.tab.files.sharepoint",
    "name": "Documents3",
    "sortOrderIndex": "10300",
    "configuration": {
        "siteUrl": "https://baywet.sharepoint.com/sites/customerhub",
        "libraryServerRelativeUrl": "/sites/customerhub/Shared Documents",
        "selectedDocumentLibraryTitle": "Documents",
        "selectedSiteTitle": "customerhub",
        "dateAdded": "2018-10-05T16:56:59.169Z"
    }
}

I get a 201 status response, my tab is added to the channel. However whenever somebody tries to upload a file from the Teams UI, they get the following error message The File {filename} is missing. If they click on Open in SharePoint and then upload the file, it works.
teams error message
If I compare with a tab created through the UI (which works properly) here is the description I get.

{
    "id": "a68e34db-9d43-4821-953b-2dec938ce785",
    "name": "Document%20Library",
    "teamsAppId": "com.microsoft.teamspace.tab.files.sharepoint",
    "sortOrderIndex": "10200",
    "webUrl": "https://teams.microsoft.com/l/channel/19%3ab2e05a0aae42487485b13e088d5d2f0f%40thread.skype/tab%3a%3aa63916e6-f252-477d-9696-7934980e7e47?label=Document%2520Library&groupId=71ed6a2e-67ca-4930-a3c2-abb25ca29fbf&tenantId=bd4c6c31-c49c-4ab6-a0aa-742e07c20232",
    "configuration": {
        "entityId": null,
        "contentUrl": null,
        "removeUrl": null,
        "websiteUrl": null,
        "siteUrl": "https://baywet.sharepoint.com/sites/customerhub",
        "libraryServerRelativeUrl": "/sites/customerhub/Shared Documents",
        "libraryId": "706FAD5678484E7B93B0855E52A0BCD9",
        "selectedDocumentLibraryTitle": "Documents",
        "selectedSiteImageUrl": "https://baywet.sharepoint.com/sites/customerhub/_api/GroupService/GetGroupImage?id='f9d430ca-4de3-42f1-9474-1427bfdb16b0'&hash=636743460492415245",
        "selectedSiteTitle": "customerhub",
        "dateAdded": "2018-10-05T16:56:59.169Z"
    }
}

The only difference being the libraryId configuration value. (you're not supposed to send in the webUrl and id). This library id doesn't match the library id in SharePoint, or the drive item id in the Graph so my question is: what value am I supposed to set for the libraryId? Is there anything else I am missing?

2
I wanted to let you know that we are looking into this and will let you know once we've figured it out.Jeremy Thake MSFT

2 Answers

0
votes

The following code Creates the team for a known Group ID (365 that When created, created a team site) and adds 3 tabs on the existing channel.

          IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                                 .Create(GraphClientId)
                                 .WithTenantId(GraphTenantId)
                                 .WithClientSecret(GraphClientSecret)
                                 .Build();
            ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
            GraphServiceClient graphClient = new GraphServiceClient(authProvider);

            var team = new Team
            {
                MemberSettings = new TeamMemberSettings
                {
                    AllowCreateUpdateChannels = true
                },
                MessagingSettings = new TeamMessagingSettings
                {
                    AllowUserEditMessages = true,
                    AllowUserDeleteMessages = true
                },
                FunSettings = new TeamFunSettings
                {
                    AllowGiphy = true,
                    GiphyContentRating = GiphyRatingType.Moderate
                }
            };

            Team addedTeam = await graphClient.Groups[GroupID].Team
                .Request()
                .PutAsync(team);

            ECGTeam ecgTeam = new ECGTeam {ProjectNumber= ProjectNumber ,GroupID = GroupID, TeamID = addedTeam.Id };

            string channelID = string.Empty;
            var channels = await graphClient.Teams[addedTeam.Id].Channels.Request().GetAsync();
            channelID = channels[0].Id;
            ecgTeam.ChannelID = channelID;

            TeamsTab newTab = addTab(targetWebUrl, "WorkingPapers", "Working Papers");
            var addedTab = await graphClient.Teams[addedTeam.Id].Channels[channelID].Tabs.Request().AddAsync(newTab);
            ecgTeam.TabWorkingPapersID = addedTab.Id;
            //DPC documents
            newTab = addTab(targetWebUrl, "DPCdocuments", "DPC documents");
            addedTab = await graphClient.Teams[addedTeam.Id].Channels[channelID].Tabs.Request().AddAsync(newTab);
            ecgTeam.TabDPCdocumentsID=addedTab.Id;
            //ContractDocuments //
            newTab = addTab(targetWebUrl, "ContractDocuments", "Contract Documents");
            addedTab = await graphClient.Teams[addedTeam.Id].Channels[channelID].Tabs.Request().AddAsync(newTab);
            ecgTeam.TabContractDocumentsID = addedTab.Id;
            //log.LogInformation(addedTab.Id);

Now, If you can help me create a Library for the said site that uses a custom content type, I will buy you coffee :-) The wealth of good documentation for MS Graph in .NET Core makes me want to cry :-(

0
votes

I found the solution a while after, sorry for not posting here earlier.

POST https://graph.microsoft.com/beta/teams/{groupId}/channels/{channelId}/tabs

{
    "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/com.microsoft.teamspace.tab.files.sharepoint",
    "name": "test",
    "sortOrderIndex": "10400",
    "configuration": {
        "contentUrl": "https://baywet.sharepoint.com/sites/NYC/test"
    }
}

Where contentUrl is the URL of the document library