Search code examples
c#.netazure-devopsazure-devops-rest-apiazure-sdk-.net

How add administrator to team in Azure DevOps using SDK or Web Api?


I try to create a team using SDK. And it creates it without any members and administrators:

WebApiTeam team = new WebApiTeam
        {
            Name = "New Team",
            ProjectId = project.Id
        };

then call

public virtual Task<WebApiTeam> CreateTeamAsync(WebApiTeam team, string projectId, object userState = null, CancellationToken cancellationToken = default);

And as a result, I have a team with the name "New Team" without any members and admins. Then i add members into team:

public Task<bool> AddMemberToGroupAsync(IdentityDescriptor containerId, Guid memberId, object userState = null, CancellationToken cancellationToken = default);
containerId = myNewTeam.id;
memberId=(user || group).id;

but how to add admins into team idk. I found that when we do this manually it call

http://{baseUrl}/tfs/{project}/{teamId}/_api/_identity/AddTeamAdmins?__v=5

I try to call this using postman but I can't authorize. Does anyone know how I can solve this issue?


Solution

  • If you are using tfs, you need to note that the Azure DevOps Command Line Interface (CLI) is available for Azure DevOps Server 2020 and Azure DevOps Services. This is stated here.

    I try to call this using postman but I can't authorize

    You need to use PAT with full scopes for certification.

    enter image description here

    Here is my test:

    enter image description here