How to add/remove member to a team in CRM dynamics using HTTPClient in C#

439 Views Asked by At

I see the code to add member to team using the class AddMembersTeamRequest. But how to add member to a team HTTPClient in web API C#.

I have tried using the uri

/api/data/v9.2/teams('{teamid}')/Microsoft.Dynamics.CRM.AddMembersTeam

but I get the error 'error in query syntax'.

how to pass the userids in the content?

1

There are 1 best solutions below

0
magicalKhachapuri On

Pleas look at this question: https://stackoverflow.com/a/65746179/5616374

Besides, you can perform the AddTeamMember with AddMembersTeamRequest which should look like this:

public static void AddMembersToTeam(Guid teamId, Guid[] membersId, IOrganizationService service)
        {
            // Create the AddMembersTeamRequest object.
            AddMembersTeamRequest addRequest = new AddMembersTeamRequest();

            // Set the AddMembersTeamRequest TeamID property to the object ID of 
            // an existing team.
            addRequest.TeamId = teamId;

            // Set the AddMembersTeamRequest MemberIds property to an 
            // array of GUIDs that contains the object IDs of one or more system users.
            addRequest.MemberIds = membersId;

            // Execute the request.
            service.Execute(addRequest);
        }

Hope it will be helpful.