Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update Application's property use Microsoft Graph REST API ? #2788

Open
FisherMS opened this issue Jan 3, 2025 Discussed in #2787 · 2 comments
Open

How to update Application's property use Microsoft Graph REST API ? #2788

FisherMS opened this issue Jan 3, 2025 Discussed in #2787 · 2 comments

Comments

@FisherMS
Copy link

FisherMS commented Jan 3, 2025

Discussed in #2787

Originally posted by FisherMS January 3, 2025

var app = AzClient.GraphClient.Applications[objectId];
app.Web.ImplicitGrantSettings.EnableAccessTokenIssuance = ap.EnableAccessTokenIssuance;
app.Web.ImplicitGrantSettings.EnableIdTokenIssuance = ap.EnableIdTokenIssuance;

 await  AzClient.GraphClient.Applications[objectId].PatchAsync(app);

When I execute up codes ,then get a throw exception.

Microsoft.Graph.Models.ODataErrors.ODataError: New password credentials must be generated using service actions.
   at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponseAsync(HttpResponseMessage response, Dictionary`2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken)
   at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory`1 factory, Dictionary`2 errorMapping, CancellationToken cancellationToken)
   at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory`1 factory, Dictionary`2 errorMapping, CancellationToken cancellationToken)
   at Microsoft.Graph.Applications.Item.ApplicationItemRequestBuilder.PatchAsync(Application body, Action`1 requestConfiguration, CancellationToken cancellationToken)
   at Aicro.AzureDeploy.Services.AzureApplicationService.UpdateAsync(Application app) in W:\Aicrosoft\ProjectTemplates\AzDeploy\AzDeploy.Core\Aicro\AzureDeploy\Services\AzureApplicationService.cs:line 102

How to update the Application's Properties?

@MartinM85
Copy link
Contributor

Seems like you are trying to update the passwordCredential property through the PATCH /applications/{id}, but it is not supported. Use the addPassword and removePassword methods to update the password or secret for an application.

var requestBody = new RemovePasswordPostRequestBody
{
	KeyId = Guid.Parse("f0b0b335-1d71-4883-8f98-567911bfdca6"),
};

await graphClient.Applications["{application-id}"].RemovePassword.PostAsync(requestBody);

var requestBody = new AddPasswordPostRequestBody
{
	PasswordCredential = new PasswordCredential
	{
		DisplayName = "Password friendly name",
	},
};

var result = await graphClient.Applications["{application-id}"].AddPassword.PostAsync(requestBody);

@FisherMS
Copy link
Author

Hi @MartinM85 Thank you , I am not want to update passwordCredential ,I Just want to update Web properites.

app.Web.ImplicitGrantSettings.EnableAccessTokenIssuance = ap.EnableAccessTokenIssuance;
app.Web.ImplicitGrantSettings.EnableIdTokenIssuance = ap.EnableIdTokenIssuance;

What do I to modify the app.Web's properties?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants