Using the Power BI API can share useful information, especially for organizations that have a lot of assets in Power BI and need them to be easily discovered. But what can the API really do for you? Let’s get into the details.

What the API will Not Give You

Some may expect that they would be able to use the API to pull down data that is found in their Power BI Reports.  However, it does not work like that.  What the API does give you is more like metadata about your Power BI assets.

For example, if you use the API to pull down Reports information, you will be able to get the following information about your Reports:

  • ID
  • Name
  • WebUrl
  • EmbedUrl

So, you will have information about the Reports, like what URL to use to embed the report in a web page, but you will not be able to extract data out of any reports.

How to Get Going with the Power BI API

The easiest place to start would be to look at some examples.  The Power BI API example solution and the Apiary website are 2 helpful resources that I have found. The example solution gives you some explanation and a downloadable sample app with C# code examples to work with the API. The Apiary website makes it quick and easy to see what kind of data will be returned from all the different API calls that are available to you.

To get any of the sample code, or your own code for that matter, working with your Power BI Service, you will need to register your client app in Azure AD.  Registering with Azure AD allows you to get a client app ID to use in requesting an authorization token.  That token will be passed in the authorization header of all your calls to the API.  See the sample code referenced above for where this will be used.

  1. Login to the Azure Portal.
  2. Click on Azure AD in the left-hand column navigation.2a
  3. Click on your Azure AD Name.3a
  4. Click on Applications.4a
  5. You’ll see a list of existing applications if they exist. Click on ADD at the bottom of the page.5a
  6. On the first screen, give your client app a relevant name and choose Web Application or Native Client. The one you choose depends on where you plan on executing code against the Power BI API.6a
  7. On the second screen, for Web Apps, put a URL for your web app. For Native Apps,  use the live login URL as shown in the screenshot below.7a
  8. After clicking the check you will be routed to the configuration page for your app. Scroll down to the “permissions to other applications” section, click “Add Application”, and choose the Power BI Service.8a8b
  9. Back on the configuration page, copy out the Client ID. You will use this in your code when making the call to generate an authorization token that will be used when making API calls.
Be Aware: There are Two Different API URLs to Use

Be aware of Normal vs. Preview API URLs for different features.  As of this moment there are two different URLs for the Power BI API:

The v1.0 URL can be used to access all Power BI information except for Reports.  To access Reports information you will have to use the Beta URL.

What Users Can Expect

When your app runs, the user will have to give the application permission to access the Power BI service on their behalf.

The authorization token allows the app to call into the Power BI API; however, what it will return is limited to what the given user has permissions to know about.  Therefore, the app will show the user the account name they are currently running as, and ask for permissions to access the Power BI API on their behalf.

They will see a prompt similar to this one:end photoThat’s it! You’re all set to go. Still have questions or want to discuss Power BI further? Find me on Twitter at @jagraham or with the hashtag #ComposerJason.


Leave a Reply

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