Skip to content

How to use Power BI REST APIs in Power Automate without a service principal

person in black shirt walking on sand

Last spring, I wrote a “how to” blog post about using Power BI REST APIs in Power Automate. You can find it here. During the months after writing it, I’ve created a bunch of more Power Automate flows reading Power BI REST APIs for example to our Power BI CoE. While working with these new flows, I noticed that there are APIs that do not support service principal at all as an authentication method. Only way to use these APIs is with a logged in O365 user account (with appropriate permissions documented in each API document page). 

This is an issue when using Power Automate as you must create an access token to read the Power BI REST APIs. The MS documented way to do that is with a service principal (in Power Automate – leaving out PowerShell, Azure functions etc approaches here). Doing any HTTP action calls to the Power BI REST APIs without the access token just does not work. Ooor does it..?

Luckily some of my colleagues know Power Automate better than I do and pointed me to an HTTP action called “Invoke an HTTP request” under HTTP with Azure AD connector

How it differs from normal HTTP call, is that it prompts for an Azure AD log in. Just what we need!

Using the Invoke an HTTP request action

So how to use it, let’s try. One of the APIs I haven’t managed to get working with service principal is Get Gateways. It should return a list of gateways for which the user is an admin. So it’s somewhat logical that as I’m unable to name a service principal as gateway admin, I can’t use that for this API. Sidenote, please Microsoft we need Admin APIs for gateways!

To get going, we create a new flow with desired trigger and then add an action “Invoke an HTTP request”. Note that this is a premium action, so you need a license.

We are prompted to add Base Resource URL which should be http://api.powerbi.com and an Azure AD Resource URI https://analysis.windows.net/powerbi/api. And sign in. This will create a new connection reference to your solution.

And that’s it! Next we insert the method and URL copied from the MS documentation and run. No need for headers or body in this API. You can always use the Try it option in the API documentation page to see if you need headers or body.

With this HTTP with Azure AD, we can call the APIs without creating the service principal. Very tempting for low code approach as I would not need to configure anything in Azure or Power BI admin settings.

I still think service principal is the preferred way to go but until Microsoft enables service principal use in all needed APIs, this will definitely be a valid way to access the APIs.

The possibilities with the data the APIs provide is endless! For example, we have created a Power BI report catalog “Power Hub” where end users can browse what reports are available and the information can be enriched with manually inserted data. Check it out in our App gallery!

Power AutomatePower BIREST API

Leave a Reply

Your email address will not be published. Required fields are marked *