POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/removePassword
Content-type: application/json
{
"keyId": "f0b0b335-1d71-4883-8f98-567911bfdca6"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.ServicePrincipals.Item.RemovePassword;
var requestBody = new RemovePasswordPostRequestBody
{
KeyId = Guid.Parse("f0b0b335-1d71-4883-8f98-567911bfdca6"),
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.ServicePrincipals["{servicePrincipal-id}"].RemovePassword.PostAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc service-principals remove-password post --service-principal-id {servicePrincipal-id} --body '{\
"keyId": "f0b0b335-1d71-4883-8f98-567911bfdca6"\
}\
'
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.serviceprincipals.item.removepassword.RemovePasswordPostRequestBody removePasswordPostRequestBody = new com.microsoft.graph.serviceprincipals.item.removepassword.RemovePasswordPostRequestBody();
removePasswordPostRequestBody.setKeyId(UUID.fromString("f0b0b335-1d71-4883-8f98-567911bfdca6"));
graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").removePassword().post(removePasswordPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\RemovePasswordPostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new RemovePasswordPostRequestBody();
$requestBody->setKeyId('f0b0b335-1d71-4883-8f98-567911bfdca6');
$graphServiceClient->servicePrincipals()->byServicePrincipalId('servicePrincipal-id')->removePassword()->post($requestBody)->wait();