It cannot be achieved via Rest API, but it can be achieved with SOAP API. Following is the code sample for your reference:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
namespace GetAdmin
{
class Program
{
static void Main(string[] args)
{
string projectname = "projectname";
string groupname = $"[{projectname}]\\Project Administrators";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri("https://vstsaccount.visualstudio.com/"));
IIdentityManagementService idms = ttpc.GetService<IIdentityManagementService>();
TeamFoundationIdentity admingroup = idms.ReadIdentity(IdentitySearchFactor.AccountName,groupname,MembershipQuery.Direct,ReadIdentityOptions.IncludeReadFromSource);
foreach (IdentityDescriptor tfi in admingroup.Members)
{
TeamFoundationIdentity member = idms.ReadIdentity(tfi,MembershipQuery.Expanded, ReadIdentityOptions.ExtendedProperties);
Console.WriteLine(member.DisplayName);
Console.WriteLine(member.GetProperty("Mail"));
}
Console.ReadLine();
}
}
}
Powershell Script:
$dllpath1 = "D:\\net45\\Microsoft.TeamFoundation.Client.dll";
$dllpath2 = "D:\\net45\\Microsoft.TeamFoundation.Common.dll";
$dllpath3 = "D:\\net45\\Microsoft.VisualStudio.Services.Common.dll";
$dllpath4 = "D:\\net45\\Microsoft.VisualStudio.Services.Client.Interactive.dll";
[System.Reflection.Assembly]::LoadFrom($dllpath1);
[System.Reflection.Assembly]::LoadFrom($dllpath2);
[System.Reflection.Assembly]::LoadFrom($dllpath3);
[System.Reflection.Assembly]::LoadFrom($dllpath4);
$uri = "https://xxx.visualstudio.com/";
$tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($uri)
$idservice = $tfs.GetService("Microsoft.TeamFoundation.FrameWork.Client.IIdentityManagementService")
$projectname = "xxx"
$groupname = "[" + $projectname + "]\Project Administrators";
$admingroup = $idservice.ReadIdentity([Microsoft.TeamFoundation.FrameWork.Common.IdentitySearchFactor]::AccountName,$groupname,[Microsoft.TeamFoundation.FrameWork.Common.MembershipQuery]::Direct,[Microsoft.TeamFoundation.FrameWork.Common.ReadIdentityOptions]::IncludeReadFromSource)
foreach ($id in $admingroup.Members)
{
$member = $idservice.ReadIdentity($id,[Microsoft.TeamFoundation.FrameWork.Common.MembershipQuery]::Expanded, [Microsoft.TeamFoundation.FrameWork.Common.ReadIdentityOptions]::ExtendedProperties)
Write-Host $member.DisplayName
Write-Host $member.GetProperty("Mail")
}