How to create “Office 365 Group” and assign user to that group using MS Graph API?

1 Answer 1


Check below for sample code to create Office 365 group and add user to this group using MS Graph API:

var newGroupName = "TestGroup";
var newGroupMailNickname = "TestGroup";
var userEmail = "userEmail";
var group = new Microsoft.Graph.Group
    DisplayName = newGroupName,
    GroupTypes = new List<String>()
    MailEnabled = true,
    MailNickname = newGroupMailNickname,
    Description = "Group Description",
    SecurityEnabled = false

var createdGroup = _graphServiceClient.Groups

Microsoft.Graph.User userToAdd = _graphServiceClient.Users[userEmail].Request().GetAsync().GetAwaiter().GetResult();                    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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