Add App to Channel Programmatically using Graph API

129 Views Asked by At

I want to install a tab app to a specific channel inside a team using graph api. The relevant documentation seems to only include adding apps to the team itself, not a specific channel. However, from the Microsoft Teams UI I seem to be able to do so.enter image description here

I attempted to do a naive request:

https://graph.microsoft.com/v1.0/teams/{{team_id}}/channel/{{channel_id}}/installedApps

That mimics the working flow for teams using the standard convention for other API calls to a specific channel, but to no luck.

I also attempted to add it via:

https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/tabs

With a request body:

{
  "displayName": "Your App Tab Display Name",
  "teamsAppId": "YourAppId",
  "configuration": {
    "entityId": "YourEntityId",
    "contentUrl": "YourContentUrl",
    "websiteUrl": "YourWebsiteUrl"
  }
}

But it returns a 500 error.

1

There are 1 best solutions below

0
Sridevi On BEST ANSWER

I have a channel named General in my Teams group, that can be retrieved using below Graph API call:

GET https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/

Response:

enter image description here

Initially, you can call below Graph API query to get teamsAppId of Forms application:

GET https://graph.microsoft.com/v1.0/appCatalogs/teamsApps?$filter=displayName+eq+'Forms'

Response:

enter image description here

To install a tab app to a specific channel inside a team, I ran below Graph request and got response like this:

POST https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/tabs

{
    "displayName": "Forms Tab App",
    "[email protected]": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{AppId_from_above_response}",
    "configuration": {
        "entityId": "YourEntityId",
        "contentUrl": "YourContentUrl",
        "websiteUrl": "YourWebsiteUrl"
    }
}

Response:

enter image description here

To confirm that, I checked the same in Teams where tab application added successfully to channel like this:

enter image description here

Reference: Add tab to channel - Microsoft Graph