Create Microsoft Team Tab with API

2020-07-27 04:45发布

问题:

I am researching the Microsoft Teams and graph API possibilities and would like to know if it is on the roadmap to be able to create and configure Tabs through the graph API.

I have seen that teams are in the graph API beta, but can't find any information about creating or configuring tabs programmatically.

Thanks!

回答1:

At this time, no such functionality exists. I would suggest adding this request to the Microsoft Teams UserVoice.



回答2:

You can do it programatically as stated below. Hope this helps

            //Creates Tab object for Dashboard
            TeamsTab teamsDashboardTab = new TeamsTab()
            {
                DisplayName ="My Dashboard",
                TeamsAppId = AppId,
                Configuration = new TeamsTabConfiguration
                {
                    EntityId = AppId,
                    ContentUrl = TargetServer + project.Id,
                    WebsiteUrl = TargetServer + project.Id
                }
            };

var teamsTab = await _graphClient.Teams[teamId].Channels[channelId].Tabs.Request().AddAsync(teamsDashboardTab);


回答3:

I found a possibility in a nice blog entry here on team.rocks by Magnus Sandtorv.

It is not documented in any way on the graph API and not visible in the graph explorer yet but basically what you do is do a POST to the graph beta endpoint like this:

POST https://graph.microsoft.com/beta/teams/<TEAMID>/channels/<CHANNELID>/tabs 
Request body:
{
    "name": "Example",
    "teamsAppId": "com.microsoft.teamspace.tab.web",
    "configuration": {
        "entityId": "<ID>",
        "contentUrl": "https://example.com",
        "websiteUrl": "https://example.com",
        "removeUrl": ""
      }
}

I myself am still looking for a list of Teams-App-IDs and exact definition of what the entityId should look like. For now i just use some number but checking in Teams in seems like it should be some kind of GUID.



回答4:

After days of research and try/error i found out: the "entityID" doesnt have any meaning (the explanation on https://docs.microsoft.com/de-de/graph/teams-configuring-builtin-tabs#word-excel-powerpoint-and-pdf-tabs is nonsense) you may even leave it blank.

Also the contentURL in the example won't work because it needs to be unescaped.