Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Power BI Community,
I'm encountering an issue that began recently and would appreciate some insights.
What I'm Doing
I'm automating the deployment of Power BI reports (.pbix files) across multiple environments – Dev, QA, and Prod – using PowerShell. Here's what the script does:
This process worked perfectly for the last 8–9 months.
Problem
Suddenly, starting June 2025, I'm getting a 401 Unauthorized error when calling the following API:
bash
CopyEdit
$apiUrl1 = "https://api.powerbi.com/v2.0/myorg/me/gatewayClusterDatasources?$expand=users"
$response12 = Invoke-PowerBIRestMethod -Url $apiUrl1 -Method Get
This was used to get the cloud gateway datasources, especially those created via "Manage Connections and Gateways" in the Power BI Service.
This API used to work with the service principal authentication – but now fails with a 401.
What I Tried
What I'm Looking For
Auth Details
Any guidance or updated documentation references would be incredibly helpful!
Thanks in advance,
Khadar Afghan
Still this issue is not resolved, any help would be appriciated.
Hi @KhadarA ,
Maybe you can have a look at the similar issue here which was resolved.
Power Bi REST API - 401 Authorization error when using Service Principals.
If you are still getting the error, please consider raising a support ticket for further assistance.
To raise a support ticket for Fabric and Power BI, kindly follow the steps outlined in the following guide:
How to create a Support Ticket
If this post helps, please Accept as solution to assist other members in finding it more easily.
Thank you for being a part of Microsoft Fabric Community Forum!
Hi @KhadarA ,
Thank you for providing such detailed write-up about your issue.
You can follow these checks to troubleshoot the problem-
1.Microsoft introduced a setting in the Power BI Admin Portal to allow service principals to use read-only admin APIs. This setting must be enabled to grant the necessary permissions. However, this setting is typically accessible only to users with administrative roles, such as Global Administrators or Power BI Service Administrators. If your account lacks these privileges, you might not be able to enable this setting yourself.
Check - Enable service principal authentication for admin APIs
2. Even after enabling the setting, it's crucial to ensure that the service principal has the appropriate permissions. Assigning permissions like Tenant.Read.All directly to the service principal in Azure AD is not recommended. Instead, permissions should be managed through the Power BI Admin Portal, where you can assign the service principal to specific security groups that have the necessary access rights.
3. The service principal needs to be explicitly granted access to the workspaces where the cloud gateway datasources are configured. It's essential to verify that the service principal has the necessary access to the specific resources you're trying to interact with.
Also check- https://community.fabric.microsoft.com/t5/Developer/Service-principals-can-access-admin-APIs-used-fo...
If you still face the issue, le me know I can help you with raising a Support ticket for that.
Hope this helps!
If the response has addressed your query, please Accept it as a solution so other members can easily find it.
Thank You!
Hi @v-sdhruv ,
Thank you for providing the instructions. I have confirmed all the above steps you have mentioned, below i will provide you all the screenshots.
I have added all my App registration in a security group. and given permission to the security group in admin portal.This is the cloud connection and i have given permission to the App through which iam calling the api.
This is the cloud gateway dataset connection. i have given owner access to the app which is calling the api.
I have given access to the same app to my workspace where iam publising the report.
User | Count |
---|---|
14 | |
6 | |
2 | |
2 | |
2 |
User | Count |
---|---|
3 | |
3 | |
3 | |
2 | |
2 |