Hi @Manoj Pant
The resource id should be the service principal id of the Microsoft Graph application.
The application id of the Microsoft Graph application is '00000003-0000-0000-c000-000000000000', and you can obtain its service principal id based on the application id.
/servicePrincipals?$filter=appId eq '00000003-0000-0000-c000-000000000000'
Code snippet:
var requestBody = new AppRoleAssignment
{
PrincipalId = Guid.Parse("{servicePrincipal-id}"),
ResourceId = Guid.Parse("{service principal id of the Microsoft Graph app}"),
AppRoleId = Guid.Parse("{appRole id}"),
};
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].AppRoleAssignedTo.PostAsync(requestBody);
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.