How do I check if a user belongs to a particular group using the AzureDevops RestAPI

Leonardo Oliveira 0 Reputation points
2023-05-30T22:50:03.1666667+00:00

I would like to know if I can get which groups a user is inserted within a project in azuredevops.

I researched and saw that before I used this endpoint to find a list of all groups of an organization and then I used the decriptor to get the list of users belonging to that group.

GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=6.1-preview.1

GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups/{Descriptor}/members?api-version=6.1-preview.1

When I try to make a request for the second url I get a 404

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,338 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. 2023-05-31T08:55:17.0433333+00:00

    Hi @Leonardo Oliveira,

    To check the groups, directory roles, and administrative units that the user is a direct member of please use the below query:

    GET /users/{id | userPrincipalName}/memberOf
    

    For more information:https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments