Create new app role in B2C via Microsoft Graph

Heather Turner 66 Reputation points
2021-02-23T22:48:18.837+00:00

Hello, Im trying to create a new app role using Microsoft Graph via B2C. Is this possible using graph or only approleassignments with already existing app roles? Here is a code snippet that I am using:

var application = new Application
                {
                    DisplayName = "HeathersTestApp022321c",
                    Description ="HeatherDescription"
                };

                await _graphServiceClient.Applications
                    .Request()
                    .AddAsync(application);

                var appRole = new AppRole()
                {
                    Id = Guid.NewGuid(),
                    DisplayName = "MyAppRole",
                    IsEnabled = true,
                    Description = "MyAppRoleDescription",
                    AllowedMemberTypes = new List<string>() { "User", "Application" }
                };
                application.AppRoles = new List<AppRole>() { appRole };

                await _graphServiceClient.Applications[http://application.Id]
                    .Request()
                    .UpdateAsync(application);

Im getting the following error on the last line when calling UpdateAsync on the application: Specified HTTP method is not allowed for the request targetenter code here

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,049 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,702 questions
{count} votes