I would like to know if there are any cli commands or rest api's to get the list of users in an Azure DevOps project. For example, In an organization if there are two projects "alpha" and "beta" with 10 users in each project. I able to get all the list of 20 users by cli or rest api's. But, how can I only get the list of users in "alpha" project?
2 Answers
Agree with Sajeetharan
We can use the API with the variable scopeDescriptor to get the list of user in one project.
Steps:
List all projects and get the "alpha" project ID.
GET https://dev.azure.com/{organization}/_apis/projects?api-version=6.0
Get the one project scopeDescriptor via Descriptors - Get
GET https://vssps.dev.azure.com/{organization}/_apis/graph/descriptors/{storageKey}?api-version=5.0-preview.1
Note: we need enter the "alpha" project ID to the field storageKey and then Copy the value of value to the scopeDescriptor field of the API shared below.
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?scopeDescriptor={scopeDescriptor}&api-version=6.0-preview.1
Then we could only get the list of users in "alpha" project.
Comments
Have you had a look at the Azure Devops REST API
you just need to set the scope with the project name.
2 Comments
Rob Ert
It's also important to remember about proper permissions assigned to your service account which will reach API.
Shoshana Tzi
pay attention, Graph work only on Azure DevOps Service, not on Azure DevOps Server
