Add a User to a Group/Team with Graph

Occasional Contributor

I know this is basic but I've been trying for hours to get this to work. The example in the docs is wrong. I want to add a user to a group/team. Here's the code at issue:


var group = new Group
AdditionalData = new Dictionary<string, object>()
{"", "{00000000-0000-0000-000000000000}"}
await graphClient.Groups["{00000000-0000-0000-0000-000000000000}"].Request().UpdateAsync(group);

 I feel like it's the odata part that I don't have right but I can't find an example that shows the correct format.

2 Replies

Hi @SHWork ,


Not sure if it is different if you are adding this via code as I just make use of the Graph for custom connectors or by way of PowerShell.


However I can confirm that the below would work as a straight call.


So in the request the GUID is the object ID of the group$ref


In the body, the GUID is the object ID of a user

No Content - 204 - 226ms
Don't forget and if not doing so, test via


Thanks for your help, doing it in c# is different. Fortunately I discovered that the beta version of the docs has the correct code.


The code to add a user to a group looks like this:



var directoryObject = new DirectoryObject
    Id = "{User ID}"
await graphClient.Groups["{Group ID}"].Members.References