I have "Reports.Read.All" permission but still cant get request of this :

Viewed 68

I want to use this request.

It is about getting activity time of users. I saw that I need Reports.Read.All permission to send this request. Then my maneger admitted this permission for me. However I still cant get a return : enter image description here

As you see, it gives this error on the photo.

1 Answers

I tried to reproduce the same in my environment and got the below results:

When I ran the same query in Graph Explorer, I'm getting CORS error like below:

GET https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(period='D7')

Response:

enter image description here

So, I tried to do the same via Postman by registering one Azure AD application and added Reports.Read.All permission without granting consent like below:

enter image description here

I generated access token via Postman with parameters like below:

POST https://login.microsoftonline.com/<TenantID>/oauth2/v2.0/token

client_id:appID
grant_type:client_credentials
scope:https://graph.microsoft.com/.default
client_secret:client_secret

Response:

enter image description here

When I used this token to call query, I got same error as you like below:

GET https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(period='D7')

Response:

enter image description here

To resolve the error, make sure to grant admin consent to Reports.Read.All Application permission like below:

enter image description here

I generated access token again after granting admin consent.

When I used that token to call the query, I got response successfully like below:

GET https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(period='D7')

Response:

enter image description here

If you granted admin consent to Reports.Read.All of Delegated type, you will still get 403 Forbidden error.

So, make sure to add Reports.Read.All of Application type and grant admin consent while using client credentials flow.

Related