Tuesday, December 14, 2021

Graph API News: API to list all Microsoft Teams in a tenant is now available


So far, to list all Microsoft Teams teams in an organization programmatically, you had to work with the groups API. I believe that the preferred approach has been to filter all groups by the resourceProvisioningOptions property to get only those groups that have teams. The following is an example of this request:

GET /groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')

However, this request returns a response that is partially helpful. On the one hand, it returns all groups that have teams. On the other hand, additional requests are needed to return team specific properties, such as isArchived, specialization, and webUrl.

The Microsoft Graph Teams team has just introduced a new BETA API that allows users to list all teams in a tenant:

GET /teams

The not-so-good part of this implementation is the limited number of properties (id, displayName, and description) that a call to GET /teams return. Basically, it gives you less data than working with the groups API that, for example, also returns the group/team’s visibility. Nevertheless, progress is progress 😀 and I appreciate the invest. In general, I hope the list of supported properties returned from a GET /teams call will increase rapidly. This would help developers to reduce the number of additional requests to retrieve all teams related properties and consequently improve applications. 

The following example shows the response of a GET/teams request. You will notice that the response body also contains a set of other properties that are returned with null, which represents a behavior similar to a call to GET/joinedTeams.

{
   "@odata.context":"https://graph.microsoft.com/beta/$metadata#teams",
   "value":[
     {
         "id":"b4f36c5f-c66e-4212-9b87-8817dabd8230",
         "createdDateTime":null,
         "displayName":"Project Alpha",
         "description":"All about the Project Alpha.",
         "internalId":null,
         "classification":null,
         "specialization":null,
         "visibility":null,
         "webUrl":null,
         "isArchived":null,
         "isMembershipLimitedToOwners":null,
         "memberSettings":null,
         "guestSettings":null,
         "messagingSettings":null,
         "funSettings":null,
         "discoverySettings":null
     },
     {
         "id":"78ee08a5-6c7d-4136-b2ca-78b049738f96",
         "createdDateTime":null,
         "displayName":"Project Alice",
         "description":"All about the Program Alice.",
         "internalId":null,
         "classification":null,
         "specialization":null,
         "visibility":null,
         "webUrl":null,
         "isArchived":null,
         "isMembershipLimitedToOwners":null,
         "memberSettings":null,
         "guestSettings":null,
         "messagingSettings":null,
         "funSettings":null,
         "discoverySettings":null
     }
   ]
}

For more details on this API, see List teams.

Keep in mind that the use of Microsoft Graph BETA APIs for production applications is not supported because BETA APIs are subject to change. I am crossing my fingers that this specific API will indeed change, for example, all teams related properties will be returned with proper values 😊

Thanks for reading,
Jarbas Horst

No comments:

Post a Comment