How to get a list of users in an Azure Devops project using an API or CLI

Viewed 3357

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

enter image description here

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.

Related