question

JolienaiRibeiroViegas-0466 avatar image
0 Votes"
JolienaiRibeiroViegas-0466 asked JamesTran-MSFT commented

Microsoft.Graph.ServiceException: Code: methodNotAllowed

I am getting 400 after sending the request below to my b2c tenant. see below more details:

Microsoft.Graph.ServiceException: Code: methodNotAllowed
Message: The method is not supported for this URL.

I need to reset the user password, so I am following what is described here: https://docs.microsoft.com/en-us/graph/api/passwordauthenticationmethod-resetpassword?view=graph-rest-beta&tabs=csharp

public async Task<string> ResetPassword(string userId)
        {
            var newPassword = Helpers.PasswordHelper.GenerateNewPassword(4, 8, 4);

            var result = await graphClient
                .Users[userId]
                .Authentication.PasswordMethods["{passwordAuthenticationMethod-id}"]
                .ResetPassword(newPassword, null)
                .Request()
                .PostAsync();

            return result.NewPassword;
        }

and here is the packages I am using

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.4" />
    <PackageReference Include="Microsoft.Graph.Beta" Version="0.39.0-preview" />
    <PackageReference Include="Microsoft.Identity.Client" Version="4.13.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
  </ItemGroup>


</Project>
azure-ad-b2cmicrosoft-graph-sdk
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Adding right tags/teams to assist

0 Votes 0 ·

1 Answer

JamesTran-MSFT avatar image
0 Votes"
JamesTran-MSFT answered JamesTran-MSFT commented

@JolienaiRibeiroViegas-0466
Thank you for your detailed post and I apologize for the delayed response!

Based off your error message and our supported B2C Graph API operations article, the "passwordAuthenticationMethod: resetPassword" API is not supported for B2C. As of right now, only the GET/Update APIs are supported via the - User flow authentication methods (beta).

Error Message:
Microsoft.Graph.ServiceException: Code: methodNotAllowed
Message: The method is not supported for this URL.

If you'd like, I'd recommend leveraging our User Voice forum to create a feature request so our engineering team can take a look at implementing this.


If you have any other questions, please let me know.
Thank you for your time and patience throughout this issue.


Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JolienaiRibeiroViegas-0466
I just wanted to check in and see if you had any other questions or if you were able to resolve this issue?

If you have any other questions, please let me know.
Thank you for your time and patience throughout this issue.

0 Votes 0 ·