Forum Discussion

ajaynathreddy's avatar
ajaynathreddy
New Member
1 year ago
Solved

I’m trying to programmatically retrieve Power BI report subscription details using the Admin API end

I’m trying to programmatically retrieve Power BI report subscription details using the Admin API endpoint:
GET https://api.powerbi.com/v1.0/myorg/admin/reports/{reportId}/subscriptions?$expand=users
Here's my setup:
- I registered an Azure AD app (client_id: [provide your ID]) and granted it API permissions:
- Power BI Service → Tenant.Read.All (Application type)
- I enabled **“Allow service principals to use Power BI APIs”** in the Power BI Admin Portal. - I'm using the client credentials (client_id + client_secret) flow to get an access token.
- The token request works and returns a valid token, but when I call the Admin API above, I receive: 401 Unauthorized.

  • Thanks for information, The Admin API worked when we "Enable service principal to access powerbi API" and Application permission in Azure portal for PowerBI service should not have Application based permission. Worked for me after I revoked admin consent for below permission.
    --->Tenant.Read.All(Should not be Application type and Revoke admin consent)

9 Replies

  • Hello ajaynathreddy 

    Possible issue

    Even with Tenant.Read.All, the 401 error occurs because Admin APIs require the app to be a Power BI Admin or have delegated user context — and application permissions alone won't work unless the service principal is granted Fabric admin rights.

     

    Solution

    Ensure the service principal is explicitly added as a Power BI Service Administrator in the Microsoft 365 Admin Center or is assigned Fabric (Power BI) Admin role via Azure AD. Without this, even with the correct API scopes, GET /admin/reports/{reportId}/subscriptions will return 401.

    Thanks

     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

    • ajaynathreddy's avatar
      ajaynathreddy
      New Member

      In powerbi admin portal, enabled service principal to access powerbi admin API and added a security group which has app as

      member, does this permission not enable admin role for the application. Still do we need explicitely assign powerbi service admin role to the app in azure AD. Thank you for responding faster.

      • Akash_Varuna's avatar
        Akash_Varuna
        Icon for Super User rankSuper User

        Hi ajaynathreddy Ensure the app has the Power BI Service Admin role explicitly assigned in Azure AD, as adding it to a security group alone doesn’t grant this role. Verify that the security group is enabled for API access in the Power BI Admin Portal. Double-check the Tenant.Read.All permission with admin consent. Retry the API call using a valid token with the appropriate scope.

  • Hi ajaynathreddy The 401 error may occur if permissions or setup steps are incomplete. Ensure your Azure AD app has Tenant.Read.All permission, and admin consent has been granted. Verify the service principal has the appropriate role in Power BI Admin Portal (e.g., Service Administrator). 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ajaynathreddy 
    Akash_Varuna pankajnamekar25 Thanks for your inputs.

    Suggestions from them is very usefull, please ask for the Power BI Service Admin role & Retry the API call it may work for 401 error. please let us know once your try all above points. 

    Thanks.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ajaynathreddy 

    I hope the information provided was helpful. If you still have questions, please don't hesitate to reach out to the community.

    • ajaynathreddy's avatar
      ajaynathreddy
      New Member

      Thanks for information, The Admin API worked when we "Enable service principal to access powerbi API" and Application permission in Azure portal for PowerBI service should not have Application based permission. Worked for me after I revoked admin consent for below permission.
      --->Tenant.Read.All(Should not be Application type and Revoke admin consent)

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi ajaynathreddy 

        Glad to hear your issue was resolved, and thank you for sharing it with the community. This will be helpful for others facing similar problems. Please accept the relevant solution. If you have any further issues, please feel free to reach out to the community. 

        Thanks.