Power BI REST API; What it is and Why it is Important

Power BI REST API. What it is and why it is important

You can interact with the Power BI objects in the Power BI Service through a set of APIs called Power BI REST API. The Power BI REST API can help automate tasks, build tools that work with Power BI, the configuration of Power BI outside of the platform, and embed Power BI into a third-party application. In this article and video, I’ll explain REST API, why it is useful, and a few examples.

Video

Power BI REST API

A REST API is a type of web service that can be used with or without some parameters and provide responses on a specific area. In the case of Power BI, Power BI REST API is a set of web services that can work with the Power BI objects in the Power BI service. There are many use cases for REST API for Power BI. Below are some examples;

  • Refreshing the dataset automatically if it failed
  • Refresh the dataset immediately after successfully finishing the refresh of all related dataflows
  • Creating a deployment pipeline
  • Embedding Power BI report or dashboard into a web application
  • Automating documentation of Power BI service objects
  • Sending data rows to a streaming dataset in the Power BI service
  • Extracting the usage of Power BI objects by the users
  • and many other scenarios.

Power BI REST APIs can be used in programming (.NET or other languages), PowerShell, and other tools. Most of the use case for the APIs is through a programming language. This article won’t go into the details of the program in which we invoke the REST API. Instead, we focus on where to get the information and the possibilities.

Getting Started

To start working with REST API for Power BI, you can go to this link; https://learn.microsoft.com/en-us/rest/api/power-bi/. This is the link to the documentation for the REST API. The REST API operation is categorized into groups to find the function you are looking for easily.

Power BI REST API Operation Groups

The list above gets updated regularly, and you can expect more functions and operations available through the REST API in the future.

Once you click on an operation group, you will see all functions under that group.

REST API functions for Power BI Reports

The list above is for the REST API functions for the Power BI Reports. If you compare this list with the Power BI Cmdlets for PowerShell for the reports, you can see how extensive the REST API list is. This shows you immediately that the REST API is more powerful than the PowerShell Cmdlets for Power BI (although the PowerShell Cmdlets are easier to use for non-programmers).

A helpful thing in the Microsoft documentation for these REST APIs is that you have the option to TRY a REST API function from the web browser page, this way you can call the function within your environment using your Power BI account and see if this is what you are looking for or not.

Trying a REST API function through the browser.

For example, if you run the Get Refresh History API for a sample dataset, you can get the response through the TRY window in the browser.

REST API sample results in the web browser

Some APIs require the Id of the objects in the Power BI service. These Ids are the unique identifier codes that can be fetched through the URL of the object in the Power BI service or even through the response of some other API functions.

Fetching a workspace Id from the Power BI service URL

Calling the API from .NET

As mentioned before, most REST API usage is from a custom application or program. C# or VB.NET are the two most commonly used languages in Microsoft world for using the REST API of Power BI. To use the REST API through these programming languages, you can download (or install) the .NET SDK for Power BI (which gets updated regularly).

This Power BI NuGet will give the programmer the list of functions to use;

Power BI functions and classes in the Power BI SDK for .NET

An example of such an application is the Power BI Helper, which uses the functions in the .NET SDK of Power BI to get some Power BI service documentation.

To get started with the .NET SDK of Power BI, an application must be registered for Power BI in your organization’s tenant active directory. Then there is an authentication process to complete. If you are interested to learn more about it and learn some samples of working with the .NET SDK of Power BI, read the article series below;

Embedding into a custom application

A common use case for the REST API of Power BI is embedding the report or dashboard into a custom web application. Power BI documentation has two good resources for that;

The first link is all the documentation you need for the Power BI Embedded. The Power BI Playground is an interesting place to run some embedded code as a test in the browser and see how it works.

Power BI Embedded Analytics Playground

The playground environment gives you a sandbox to see how code results perform in the application, get the sample codes, and even run it for your tenant.

Testing codes in the Power BI Embedded playground

Power Automate

Some of the most common REST API functions for Power BI are streamlined through Power Automate. Power Automate is a service for designing flow and automation. You can, for example, use the Power BI functions in automate to do tasks like the below;

Power Automate includes a user-friendly UI; you don’t need to be a programmer to work with the Power BI functions there. An example of using Power Automate functions for Power BI is using Power Automate to trigger as soon as an entry to a Microsoft Form is submitted and send the result to a real-time streaming Power BI dataset.

PowerShell to call REST API

Another approach to call the REST API is through a PowerShell command called Invoke_RestMethod. Here is the documentation of this function with some samples of how to use it.

Summary

Power BI REST APIs are web services that can work with the Power BI service objects (such as workspaces, datasets, dataflows, reports, etc.). Using the REST API, a programmer can use a custom application to automate some configurations for a Power BI service solution and extend the solution to another level. Things that are not possible through the normal GUI of the Power BI service might be possible options through the REST API.

Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for 12 continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand, Power BI Summit, and Data Insight Summit.
Reza is author of more than 14 books on Microsoft Business Intelligence, most of these books are published under Power BI category. Among these are books such as Power BI DAX Simplified, Pro Power BI Architecture, Power BI from Rookie to Rock Star, Power Query books series, Row-Level Security in Power BI and etc.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.

Leave a Reply