Add user in Teams group/channel.

Occasional Contributor

I have 2 string values a user and Teams group , how do I add a user in the teams group using c#?

1 Reply


Hello, nellietheelephant, here is the answer to your question:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var conversationMember = new AadUserConversationMember
        Roles = new List<String>()
        AdditionalData = new Dictionary<string, object>()
                {"email address removed for privacy reasons", "'8b081ef6-4792-4def-b2c9-c363a1bf41d5')"}

await graphClient.Teams["{team-id}"].Members

If you need more details on how to add a member to a team using the user principal name or other options, check this documentation. In case you are interested in important tips for Microsoft 365 administrators, check this page here.