restazure-devopsazure-devops-rest-apiazure-devops-server

Get Members of a Group in Azure DevOps Server 2022


I need to know the way to get the users of a specific group through the REST API of Azure DevOps Server 2022, that is, on-premise. We are going to use as an example url 192.168.0.1 and the DefaultCollection as practice purposes. I have searched the documentation but when I try to apply them in my case they don't work for me, I get a 404 Not Found.

For now I am doing:

http://192.168.0.1:8080/tfs/_apis/groupentitlements?api-version=6.0-preview.1 http://192.168.0.1:8080/tfs/DefaultCollection/_apis/groupentitlements?api-version=6.0-preview.1

Neither seems to work. They throw 404.

I don't know if it has something to do with it, but I was reading on this website that a "vsaex" prefix is used for groupentitlements, "vssps" for graph and "status" for status, so I tried the following: http://vsaex.192.168.0.1:8080/tfs/_apis/groupentitlements?api-version=6.0-preview.1 http://vsaex.192.168.0.1:8080/tfs/DefaultCollection/_apis/groupentitlements?api-version=6.0-preview.1

Again, neither seems to work.

Also I tried differents api-versions, or without using any of them. I don't have any trouble using other parts of the REST API, e.g.: I can get Projects of a collection, Teams by Project, etc. and they work fine.


Solution

  • After some research I found that with this call you can GET what I was searching.

     - http://{server:port}/tfs/{collection}/_api/_identity/ReadGroupMembers?scope={groupId}&readMembers=true&api-version=6.0
       you can do that.
    

    If you need the groupId you can get it from:

     - http://{server:port}/tfs/{collection}/_apis/identities?searchFilter=General&filterValue={group
       Name}&api-version=6.0
    

    If you have more than 1 group called the same, search in the response the group that you want in providerDisplayName property -> [{ProjectName}]\\{Group Name} There you will get the groupId and from that you can get the Members of a Group

    The weird thing is that you have tu use _api/_identity instead of _apis/identities.