Use a Power BI Tile in your web page

Creating dashboards is more witchcraft than art and more art than science. Think about how many times you have banged your head to produce a useful chart according to the specs of your client. You have the numbers, you have the chart and everything in place but the customer keeps saying: “it’s just not the right shade of green…”


Many times we have to create custom web pages to accomplish what the BI solution can’t offer out of the box; and Power BI provides you just that, the ability to use a tile from a dashboard without forcing the customer to open the entire Power BI user interface. With this technique you can embed just a piece of a bigger BI report into an HTML page. It’s not very straightforward (at least for me it wasn’t), and I must say that the documentation often makes it worse (there’s an errata in the GET REST Uri of the Step 3 – Get user’s tile information).


So you want to embed a Power BI Tile into a web page: to quickly see how it works go to this example page. If you want more details, just read on.

I assume you already have a Power BI dashboard and you know how to get an access token. This is probably the most difficult part and I covered that in another article.


I am using cURL from a headless EC2 server just for sake of simplicity, you can do this with your favorite programming language.


First step is to get the ID of your dashboard:




curl -k -X GET "https://api.powerbi.com/beta/myorg/da..." -H "$AUTH_HEADER_LOCAL"


where $AUTH_HEADER_LOCAL is the “Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiI……..” you created when asking for an access token.


The server will respond something like this:

recorte


From here you need to extract the id element which represents your dashboard.


Second step is to get the tile ID:




curl -k -X GET https://api.powerbi.com/beta/myorg/da... -H "$AUTH_HEADER_LOCAL"


where $AUTH_HEADER_LOCAL is the same as above and ${DASHBOARD_ID} is the value you got in step 1.


recorte

the answer will include an element named “embedUrl” which is the link to your tile.


Now that you have the embedUrl and the access token, you can build a simple HTML page:



Create an element that will host your tile
Have your access token ready into a variable, I personally have it in an external .js file that I load as a
Add a element to activate the with the access token and the dimensions of the tile




Note that the access token will expire after 1 hour, so you need to have a way to refresh it on the server side.


Feel free to use http://powerbitile.azurewebsites.net/ as a reference.


Filed under: Azure, Big DAta, dashboards, OAuth, Power BI, Web service Tagged: Advanced, API, Big Data, curl, Microsoft PowerBI, OAuth, tutorial, Web Services
 •  0 comments  •  flag
Share on Twitter
Published on November 30, 2015 04:11
No comments have been added yet.