0

I am trying to get all servicePrincipals for a tenant using this API call, I want to expand it to get ServicePrincipals role assignment, I am using the following GET request but I am not getting the required response.

https://graph.microsoft.com/v1.0/servicePrincipals/?$expand

How do I check which all fields the API can return using expand?

This is the API link https://learn.microsoft.com/en-us/graph/api/serviceprincipal-list?view=graph-rest-1.0&tabs=http

Shambhavi Rai
  • 321
  • 4
  • 19

2 Answers2

0

If you want to get app role assignments, simply add $expand=appRoleAssignments to your request URL. So your request URL will be:

https://graph.microsoft.com/v1.0/servicePrincipals?$expand=appRoleAssignments
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • 2
    If OP wants to list appRoleAssignments granted for a service principal, should it be `$expand=appRoleAssignedTo`? – Allen Wu May 12 '21 at 07:55
0

If you want to list appRoleAssignments granted for a service principal, can try this:

https://graph.microsoft.com/v1.0/servicePrincipals?$expand=appRoleAssignedTo

enter image description here

Carl Zhao
  • 8,543
  • 2
  • 11
  • 19