sudip dutta
sudip dutta

Reputation: 23

create mailbox along with Create users graph api in o365

We have a requirement to create office 365 user with mail account through create_user graph api. But user has been created successfully but mail account did not created.

Let us know api name to create user with mail account directly through api.

Upvotes: 1

Views: 3650

Answers (2)

jb0932
jb0932

Reputation: 41

To do this through the graph API you need to have a license that has Exchange Online as a service plan like Microsoft 365 F3 (SPE_F1), assign your new user one these licenses on creation and a Mailbox will be created for them:

Post the following:

{
    "addLicenses": [
        {
            "skuId": "your SPE_F1 skuId number"
        }
    ],
    "removeLicenses": []
}

to:

https://graph.microsoft.com/v1.0/users/{user - id}/assignLicense/

Upvotes: 0

Dev
Dev

Reputation: 2464

Microsoft Graph API doesn't has the feature. For mailbox creation, you need to use Exchange PowerShell to do it using New-Mailbox cmdlet. You can automate the Exchange PowerShell with .Net as well :)

For example,

 $password = Read-Host "Enter password" -AsSecureString
 New-Mailbox -UserPrincipalName [email protected] -Alias chris -Database "Mailbox Database 1" -Name ChrisAshton -OrganizationalUnit Users -Password $password -FirstName Chris -LastName Ashton -DisplayName "Chris Ashton" -ResetPasswordOnNextLogon $true

Upvotes: 3

Related Questions