Search code examples
graphazure-active-directoryazure-authenticationazure-ad-b2b

Updating mobileNumber using graph giving { }


I would like to add phone number to existing Azure AD users. I don't want them to manually enter their phone numbers to get code for MFA.

I am trying to do this from graph like this:

PATCH https://graph.microsoft.com/v1.0/users/id

{
  "mobileNumber" : "############"
}

This gave me No content - 204 status with empty brackets { }

Now I can see phone number added on user profile but it is still asking users to enter phone number to get code.

How can automate this process? Any ideas

PS: I have administrator role on my tenant so I hope I'm not missing any permissions.


Solution

  • Please note that, you need to create phone authentication method instead of updating mobileNumber property in user's profile.

    I tried to reproduce the same in my environment and got below results:

    To create phone authentication method, I used below graph query:

    POST https://graph.microsoft.com/v1.0/users/<userID>/authentication/phoneMethods
    
    {
    "phoneNumber": "+91 9xxxxx4004",
    "phoneType": "mobile"
    }
    

    Response:

    enter image description here

    When I checked in Azure Portal, phone number added successfully in user's Authentication methods like below:

    Go to Azure Portal -> Azure Active Directory -> Users -> Your user -> Authentication methods

    enter image description here

    When user tried to sign in, it automatically displayed added phone number like below:

    enter image description here

    When user selected that option, they will receive code to their phone number which they need to enter here:

    enter image description here