Forum Discussion
401 Unauthorized When Calling Power BI Cloud Gateway REST API with Service Principle
- 1 year ago
Hi KhadarA ,
Sorry you are still facing the issue.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
Hope this helps!
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-for-updates-or-can/m-p/4071908
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.