0
votes

Is there an end-to-end sample provided to query for the list of members and their basic profiles, including Teams user IDs and Azure Active Directory (Azure AD)?

I am following https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json and microsoft graph Postman collection, however it seems too complex for me to understand.

I need to fetch all the userId under for my MS Team

3
So far I know there is no such a way where you can get all together. You have to get it partially by each API calling. - Md Farid Uddin Kiron

3 Answers

2
votes

The document you are following is indeed used to get the information you need, including Teams user IDs and Azure Active Directory (Azure AD).

I'm not sure where you don't quite understand. But it's strongly suggested to firstly learn about Bot Framework Rest API reference.

You should pay attention to how to get the Base URI (serviceUrl). After that, you could issue a GET request on /conversations/{teamId}/members/, using the value of as the endpoint: serviceUrl.

Like this:

GET https://{serviceUrl}/v3/conversations/{teamId}/members/
Authorization: Bearer {access token}
Content-Type: application/json

For details about how to obtain an access token for your bot, see Authenticate requests from your bot to the Bot Connector service.

Now you have the request endpoint and headers. You could test the Rest API in Postman.

0
votes

Below are the commands I used to fetch Team user IDs

  1. Step 1: Request an access token from the Azure AD v2 account login service
  2. Step 2: Obtain TenantID
  3. Step 3: Get User Access Token https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

  4. Step 4: Call My Joined Team, get ID https://graph.microsoft.com/v1.0/me/joinedTeams

  5. Step 5: Findchannels of a team https://graph.microsoft.com/v1.0/teams/{{TeamId}}/channels
  6. Step 6: Find all the user profile using following https://{{serviceUrl}}/v3/conversations/{{channelid}}/members/
0
votes

The best way to get teams user details is by fetching roster details.

You can also use Graph API for getting members of a team/group. But this API provides basic details of user. like

[
    {
        "@odata.type": "#microsoft.graph.user",
        "id": "xxxxxxx-95ea-xxxxxxxxx",
        "businessPhones": [
            "xxxxxxxxxxxxx"
        ],
        "displayName": "Vivek",
        "givenName": "Vivek",
        "jobTitle": "xxxxxxxx",
        "mail": "[email protected]",
        "mobilePhone": "xxxxxxxxxxx",
        "officeLocation": "LINCOLN xxxxxxxxx",
        "preferredLanguage": null,
        "surname": "Shah",
        "userPrincipalName": "[email protected]"
    },
]