Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 824
irudne Avatar asked Nov 15 '25 17:11

irudne


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.

like image 82
Vito Liu Avatar answered Nov 17 '25 10:11

Vito Liu


Have you had a look at the Azure Devops REST API

you just need to set the scope with the project name.

GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?subjectTypes={subjectTypes}&continuationToken={continuationToken}&scopeDescriptor={scopeDescriptor}&api-version=6.0-preview.1

like image 43
Sajeetharan Avatar answered Nov 17 '25 09:11

Sajeetharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!