1

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.

  • Updated answers below. Consider upvoting it and accept it as answer. So it can be useful to others in the community as well :) – Dev Jan 19 '21 at 07:54

2 Answers2

3

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 chris@contoso.com -Alias chris -Database "Mailbox Database 1" -Name ChrisAshton -OrganizationalUnit Users -Password $password -FirstName Chris -LastName Ashton -DisplayName "Chris Ashton" -ResetPasswordOnNextLogon $true
Dev
  • 2,428
  • 2
  • 14
  • 15
0

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/
jb0932
  • 11
  • 3