How to connect Power BI with secure APIs (Token)

Juliana Nascimento
Comunidade XP

--

This was a challenge for me because I didn't know how I could connect these tools in a secure & automated way. And then, we have it: an automated dashboard that brings us all the information we need.

First, you will need a Windows environment to install Power BI. It could be your computer or a remote server.

With the tool installed, click on Get data and then on Web, as in the image below.

Image 1: Power BI access to new source

In this pop-up, paste the API URL, and write your encrypted token in your parameters. You can use any free tool to encode your token. I used this one.

Image 2: pop-up from Web — our data source

The pop-up is going to be like this one:

Image 3: pop-up From Web with needed information written

Click at Transform data to open Power Query Editor.

Image 4: opening Power Query Editor

At the Advanced Editor, we have our DAX code. Yours needs to be something like this:

let
Fonte = Json.Document(Web.Contents("https://yourapiurl.com", [Headers=[Authorization="Basic YourBearerTokenEncrypted= "]])),
in
Fonte

That's it! Your dashboard is now ready: connected and updated with your API.

Image 5: Information returned from the API, used in the Dashboard

--

--

Juliana Nascimento
Comunidade XP

Curious, applied and determined, I’ve always had a passion for writing. Started here to share my point of everything I learn. Working with IT Quality and Data .