azure - Microsoft Graph API - Update phoneMethods is no longer working - Stack Overflow

admin2025-04-17  6

Suddenly my application is no longer able to update phoneAuthenticationMethod when it's created on B2C.

UPDATE STEPS TO REPRODUCE ISSUE:

  1. Enable MFA using Custom Policy starter pack from MS()

  2. Create user in B2C and add MFA(SMS) to it using custom policy above

  3. Get User MFA using Graph API to confirm that MFA was created

  1. Try to patch MFA using Graph API, but getting error below

Portal:

Suddenly my application is no longer able to update phoneAuthenticationMethod when it's created on B2C.

UPDATE STEPS TO REPRODUCE ISSUE:

  1. Enable MFA using Custom Policy starter pack from MS(https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/tree/main/SocialAndLocalAccountsWithMfa)

  2. Create user in B2C and add MFA(SMS) to it using custom policy above

  3. Get User MFA using Graph API to confirm that MFA was created

  1. Try to patch MFA using Graph API, but getting error below

Portal:

Share edited Feb 11 at 13:49 Rohirrim asked Jan 31 at 1:45 RohirrimRohirrim 1761 silver badge10 bronze badges 7
  • Could you try running GET https://graph.microsoft.com/v1.0/users/{USERID}/authentication/phoneMethods first and check what response you are getting and add it in question? – Sridevi Commented Jan 31 at 3:36
  • @Sridevi done!! – Rohirrim Commented Jan 31 at 13:52
  • Could you confirm whether user ids are same in both calls? Please include Portal images too – Sridevi Commented Jan 31 at 14:28
  • @Sridevi sure, I have updated my question – Rohirrim Commented Jan 31 at 15:07
  • Could you confirm whether PATCH request is working or not if phone authentication is created from Graph API? – Sridevi Commented Feb 3 at 3:59
 |  Show 2 more comments

1 Answer 1

Reset to default 2

The error occurs if you try to update the phone method when there is no existing mobile number added to that user as authentication method.

I have one user with phone authentication method added in office phoneType as below:

When I tried to update that phone method as mobile phoneType and Id as 3179e48a-750b-4051-897c-87b9720928f7, I too got same error like this:

PATCH https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/3179e48a-750b-4051-897c-87b9720928f7
{
  "phoneNumber": "+1 2065555554",
  "phoneType": "mobile"
}

Response:

As mentioned in this MS Document,

The value of phoneMethodId changes depending on phoneType you want to update:

  • b6332ec1-7057-4abe-9331-3d72feddfe41 to update the alternateMobile phoneType.
  • e37fc753-ff3b-4958-9484-eaa9425c82bc to update the office phoneType.
  • 3179e48a-750b-4051-897c-87b9720928f7 to update the mobile phoneType.

In your case, initially fetch the list of phone methods added to user with below API call:

GET https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/

Response:

If mobile phoneType is not present in response, make use of POST call to add it as authentication method like below:

POST https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/
{
  "phoneNumber": "+1 2065555554",
  "phoneType": "mobile"
}

Response:

You can now update this using PATCH call as phone method of mobile phoneType is existing now:

PATCH https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/3179e48a-750b-4051-897c-87b9720928f7
{
  "phoneNumber": "+1 2055555555",
  "phoneType": "mobile"
}

Response:

To confirm that, I checked the same in Portal where phone method of mobile phoneType update successfully:

转载请注明原文地址:http://www.anycun.com/QandA/1744883347a88975.html