List appRoleAssignments granted to a service principal

Sheshagiri Mahankali 20 Reputation points
2023-03-16T02:16:56.8966667+00:00
https://graph.microsoft.com/v1.0/servicePrincipals/{objectId}/appRoleAssignedTo
I am trying to access above API through postman and below is the response. Could you please let me know what the actual error is :

I tried 
{
    "error": {
        "code": "Request_ResourceNotFound",
        "message": "Resource '' does not exist or one of its queried reference-property objects are not present.",
        "innerError": {
            "date": "2023-03-16T02:11:01",
            "request-id": "4f4f0a12-6f46-4512-ba61-83be15b2e604",
            "client-request-id": "4f4f0a12-6f46-4512-ba61-83be15b2e604"
        }
    }
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,450 questions
{count} votes

Accepted answer
  1. Shivam Dhiman 5,946 Reputation points
    2023-03-16T05:48:15.5833333+00:00

    Hi @Sheshagiri Mahankali

    As per the MS Graph document, you can address the service principal using either its id or appId.
    Id and AppId are referred to as the Object ID and Application (Client) ID, respectively, in the Azure portal

    There are two ways to list appRoleAssignments.

    1. [GET /servicePrincipals(appId='{appId}')/appRoleAssignments] .
    2. https://graph.microsoft.com/v1.0/servicePrincipals/{Id}/appRoleAssignedTo (the ID should be the servicePrincipal ID).

    I was able to replicate the issue if I am using appid in the request url:
    User's image

    Using service principal ID in the below request, I was able to get desired response.User's image

    Using [GET /servicePrincipals(appId='{appId}')/appRoleAssignments]
    4

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful