1

Currently I am able to add member to the Office 365 groups using the following Graph API.

POST https://graph.microsoft.com/v1.0/groups/{id}/members/$ref
Content-type: application/json
Content-length: 30

{
  "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}

But I am able to add only one user per request. Is there any way to add multiple users in a single call?

1

To add multiple users, we need to make a separate call each to add them to a group.

However, we can combine these requests together using batching as mentioned below:

POST https://graph.microsoft.com/v1.0/$batch
Accept: application/json
Content-Type: application/json

In the body, you can specify the requests somewhat as below:

{
      "requests": [
        {
          "id": "1",
          "method": "POST",
          "url": "/v1.0/groups/{id}/members/$ref"
          "body": {
              "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
            }
        },
        {
          "id": "2",
          "method": "POST",
          "url": "/v1.0/groups/{id}/members/$ref"
          "body": {
              "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
            }
        },
        {
          "id": "3",
          "method": "POST",
          "url": "/v1.0/groups/{id}/members/$ref"
          "body": {
              "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
            }
        }
      ]
}

More details - Multiple requests in one HTTP call using JSON batching

Test it out in - Graph Explorer

Currently we can combine maximum 20 individual requests - JSON Batching limitations

  • 1
    Thank you for your help . I tried it by myself, it is working as expected. In each object of the request the header need to be added as below. { "id": "2", "method": "POST", "url": "groups/{id}/members/$ref", "body": { "@odata.id": "https://graph.microsoft.com/beta/directoryObjects/{id}" }, "headers": { "Content-Type": "application/json" } } – Prakash Sep 10 '18 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.