I want to retrieve the service principal object given an application ID.
The .NET SDK provides the following endpoint for that:
GET /servicePrincipals(appId='{appId}')
However, I don’t see how to call that endpoint, only the one with the service principal’s object ID:
await graphClient.ServicePrincipals[applicationId].PatchAsync(new ServicePrincipal
{
AccountEnabled = false
}, cancellationToken: cancellationToken);
Any ideas?
https://learn.microsoft.com/en-us/graph/api/serviceprincipal-get?view=graph-rest-1.0&tabs=csharp
Furthermore, would it be possible to disable the service principal in a single call, instead of two, given the application ID?
2
Answers
I have called the below API using Graph Exporer and it give me the serviceprincial object for a specific application id.
We can fetch the serviceprincipal object of the specific application id using OData filter query parameter in C# as below.
The SDK should have the method
ServicePrincipalsWithAppId
The PATCH is also possible