1
votes

I'm trying to create a Group in office 365 using Microsoft Graph and add members to it. However most of the members are external to the organisation, in other words their email addresses don't have the same domain. Is this possible to do using the Microsoft Graph API? or is there a work around that will do something similar.

Essentially all I need is a distribution list (similar to Google Groups) to which I can add members, regardless of the email domain I can do this using the web interface but it seems like you can't create distribution lists via the API.

Thanks in advance.

1

1 Answers

0
votes

External users are represented as users within AD. Chance are you've noticed some user objects have a userPrincipalName that looks something like alias_domain#EXT#@tenant.domain. If you execute the query https://graph.microsoft.com/v1.0/users?$filter=userType eq 'Guest'&$select=id,displayname,mail,userPrincipalName,userType in Graph Explorer you'll get something along the lines of:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,mail,userPrincipalName,userType)",
    "value": [
        {
            "id": <GUID>,
            "displayName": <email address>,
            "mail": <email address>,
            "userPrincipalName": "<email>#EXT#@<tenant>",
            "userType": "Guest"
        },
        ...
    ]
}

These Guest users can be added to a Group using the same method you would use to add a standard user account.

Before you can add a net-new external user to a Group, you'll first need to create this user.

Elio Struyf wrote an excellent blog post that walks you through this process: Adding guests to an Office 365 Group via the Microsoft Graph API.