creating a user via the microsoft graph api

Based on the error you are provided it seems to be you are not having right permission to create the user.

In the token, you are missing the permissions, so before making the graph request you need to have the token with

User.ReadWrite.All, Directory.ReadWrite.All.

enter image description here

I made the below request, without having the required permission then I received the same error as you can see below enter image description here

Then later I added the permissions and requested for the new token, then made the graph call. Now I was successfully able to create the user enter image description here enter image description here


curl --location --request POST '' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{​​​​ "accountEnabled": true, "displayName": "displayName-value", "mailNickname": "mailNickname-value", "userPrincipalName": "[email protected]", "passwordProfile" : {​​​​ "forceChangePasswordNextSignIn": true, "password": "[email protected]" }​​​​ }​​​​'

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top