How To Access Microsoft Teams Graph API In Power Automate

Graph API can be used to automate the Microsoft Teams lifecycle such as creating teams, channels, adding members etc.
 
Refer to this link to see the list of Graph API’s available for Microsoft Teams.
 
You will see how to retrieve all the teams by calling Graph API in flow.
 
The list of all teams is here.
 
In this article, you will see how to perform the following tasks,
  • Register an Application in Azure - Register an app in Azure AD and add the required permissions to access the Graph API
  • Create flow – Access Teams Graph API Create an Automation Account

Register an application in Azure

 
Register an application in Azure AD to access the Teams Graph API.
  1. Navigate to Azure portal.
  2. Search for App Registrations. Click App Registrations as show below.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Click New Registration.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Enter the Name and click Register.

    How To Access Microsoft Teams Graph API In Power Automate
  1. App registered successfully. In the left navigation, click API Permissions.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Click Add a permission.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Select Microsoft Graph API as shown below.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Click Application Permissions.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Select Read.All permissions and click Add permissions.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Click Grant admin consent.

    How To Access Microsoft Teams Graph API In Power Automate

    How To Access Microsoft Teams Graph API In Power Automate
  1. In the left navigation, click Overview. Copy the Application (client) ID and Directory (tenant) ID values. These values will be used in Flow for authentication.

    How To Access Microsoft Teams Graph API In Power Automate
  1. In the left navigation, click Certificates & secrets. Click New client secret.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Enter the description and click Add.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Copy the secret value which will be used in flow for authentication.

    How To Access Microsoft Teams Graph API In Power Automate

Create Flow

 
Following trigger (manually starts) and actions will be used in this flow.
 
How To Access Microsoft Teams Graph API In Power Automate 
  1. Navigate to Power Automate portal.
  2. Create a new flow.
  3. Trigger - Manually trigger a flow,

    How To Access Microsoft Teams Graph API In Power Automate
  1. Action – Initialize Variable (renamed as Directory ID): Copied from App Registration overview page (Directory (tenant) ID) – refer to step 11 in the previous section.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Action – Initialize Variable (renamed as Application ID): Copied from App Registration overview page (Application (client) ID) – refer to step 11 in the previous section.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Action – Initialize Variable (renamed as Secret): Refer to step 14 in the previous section.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Action – Initialize Variable (renamed as URI): Graph API URI - https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&$select=displayName

    How To Access Microsoft Teams Graph API In Power Automate

    List all teams here.
  1. Action – HTTP: Configure HTTP action as shown below.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Enter the name for the flow and save it.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Click Test to test the flow. Click Run flow.

    How To Access Microsoft Teams Graph API In Power Automate
  1. Flow ran successfully.

    How To Access Microsoft Teams Graph API In Power Automate
  1. JSON Output – Listed all the teams within the tenant.

    1. {  
    2.   "@odata.context""https://graph.microsoft.com/beta/$metadata#groups(displayName)",  
    3.   "value": [  
    4.     {  
    5.       "displayName""M365Chennai"  
    6.     },  
    7.     {  
    8.       "displayName""Events2020"  
    9.     },  
    10.     {  
    11.       "displayName""Demo"  
    12.     },  
    13.     {  
    14.       "displayName""Tech Reads"  
    15.     },  
    16.     {  
    17.       "displayName""Automation Testing"  
    18.     }  
    19.   ]  
    20. }   

Summary

 
Thus, in this article, you saw how to access Microsoft Teams Graph API in Power Automate.


Similar Articles