Is there any possibility to add multiple users to multiple groups using the Graph Api library methods or using HTTP requests in C#?

Razvan-Lucian Buzea 21 Reputation points
2020-10-26T10:29:51.807+00:00

Just as the title says, I was wondering if I could use some methods from the Microsoft Graph API library to add multiple users to multiple groups (add members for shortly), or if I could make HTTP requests in c# to be able to add multiple users into multiple groups.

From what I've found out until now, On the web interface of Azure portal, you can select multiple users and add them to multiple groups. I've also read that you could do the same using Powershell scripts, and I was wondering if you could do the same using HTTP requests or the API's library methods.

As for a little background: I've managed to add 10k users into a group, and I want to see if it's possible to add these 10k users into two groups or more, in one call

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,420 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shiva Keshav Varma 411 Reputation points
    2020-10-26T16:27:36.527+00:00

    No, there is a single call that adds members to a group as shown below.

    PATCH https://graph.microsoft.com/v1.0/groups/{group-id}

    {  
      "members@odata.bind": [  
        "https://graph.microsoft.com/v1.0/directoryObjects/{id}",  
        "https://graph.microsoft.com/v1.0/directoryObjects/{id}",  
        "https://graph.microsoft.com/v1.0/directoryObjects/{id}"  
        ]  
    }  
    

    You can check this documentation

    If you want to add the same users to different group, you can use a for loop and use this call by changing the group id.

    (If the reply was helpful please don't forget to upvote or accept as answer, thank you)

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.