Forum Discussion
Gateway info from Power BI API in PowerShell
Hi,
So Ive got all manner of data out of the Power BI REST API using PowerShell, using both a Native & Web app.
Im trying to hit this API and getting a 401 across the board though I got it working a few weeks back strangely...
https://api.powerbi.com/v1.0/myorg/gateways
The user is an admin on all of my data Gateways & the apps have all the perms in Power BI.
Is there a template example someone could provide, where this just works or any ideas? Its obviously auth but I dont see what Id need to alter (or even how I got some of it working a few weeks back).
Here's the script Im using...
https://github.com/cporteou/Powershell_PowerBI/blob/master/PowerBI_API_Gateway.ps1
Thanks
Login to Azure portal with the user that you use for the API requests and navigate to the APP and then click on Required permissions and then click Grant Permissions. This will assign all permissions to that user (11 permissions for Power BI Service). That solved the issue for me.
You may also need to generate a new login token for the user after that...
Let me know if that worked for you.
9 Replies
- Eric_ZhangMicrosoft Employee
cporteous wrote:
Hi,
So Ive got all manner of data out of the Power BI REST API using PowerShell, using both a Native & Web app.
Im trying to hit this API and getting a 401 across the board though I got it working a few weeks back strangely...
https://api.powerbi.com/v1.0/myorg/gateways
The user is an admin on all of my data Gateways & the apps have all the perms in Power BI.
Is there a template example someone could provide, where this just works or any ideas? Its obviously auth but I dont see what Id need to alter (or even how I got some of it working a few weeks back).
Here's the script Im using...
https://github.com/cporteou/Powershell_PowerBI/blob/master/PowerBI_API_Gateway.ps1
Thanks
The Power scripts appears good. As to the 401 error, in Azure portal, please ensure the registered Azure AD APP to which the client_id and client_secret belong has sufficient permission. The Power BI service has all delegated perssions(11).
Before in PowerShell, you could also try to hit that REST API in POSTMAN.
- cporteousMost Valuable Professional
Hi Eric,
Thanks for the response.
Ill try POSTMAN. The app was created from https://dev.powerbi.com/apps and it has all 11 delegated permissions for PowerBI.
Ta
- izurevFrequent Visitor
how was this solved?
I'm having the same issue - seeing 401 error when querying for the gateways using the Power BI API - other endpoints are working fine.
Also, checked and i see all 11 delegated permissions on the App side.
Thanks in advance,
Alex
- cporteousMost Valuable Professional
I still don't have this solved.
The app can query all other aspects of Power BI through the API but always returns a 401 for Gateway calls
- izurevFrequent Visitor
Login to Azure portal with the user that you use for the API requests and navigate to the APP and then click on Required permissions and then click Grant Permissions. This will assign all permissions to that user (11 permissions for Power BI Service). That solved the issue for me.
You may also need to generate a new login token for the user after that...
Let me know if that worked for you.