Taylor Southwick
Taylor Southwick

Reputation: 1496

Add a security group to a security group fails with Request_BadRequest

I'm attempting to use the .NET Microsoft.Graph SDK to create two groups and add one to the other. The group creation is fine and they show up in the Microsoft Graph Explorer. However, when I attempt to add the group to the other group, I get an error:

Microsoft.Graph.ServiceException
  HResult=0x80131500
  Message=Code: Request_BadRequest
Message: An invalid operation was included in the following modified references: 'members'.

Inner error

  Source=Microsoft.Graph.Core
  StackTrace:
   at Microsoft.Graph.HttpProvider.<SendAsync>d__19.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__36.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.BaseRequest.<SendAsync>d__31.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at [mycode].cs:line 170

I'm adding the group with the following:

await _serviceClient.Groups[memberGroup.Id]
    .Members
    .References
    .Request()
    .AddAsync(new Group { Id = adminGroup.Id });

Edit These are security groups

Upvotes: 3

Views: 321

Answers (2)

Seiya Su
Seiya Su

Reputation: 1874

Nested Groups are not supported in Groups so what you are seeing is correct: when adding a Group, you are adding the Group members but not the group itself We cannot nest the security group in O365 too.

If you config your code rightly, you should getting the fllowing tip: "The request is currently not supported."

Upvotes: 0

Marc LaFleur
Marc LaFleur

Reputation: 33114

Office 365 Groups ("groupTypes": ["Unified"]) don't support "nested" Groups (Adding one Group as Member of another Group). Only Security Groups may contain nested Groups. From the documentation:

You can add only users to Office 365 Groups.

Upvotes: 1

Related Questions