How to use Power BI API to generate Power BI workspace content
Published Jun 06 2023 08:53 AM 2,758 Views
Microsoft

This sample shows how to use Power BI API to generate Power BI content from specific Power BI workspace. We have uploaded the example API request in GitHub repository, you can download the API request examples and test it out in your environment.

 

Prerequisites

  • An active Azure subscription. If you don't have one, create a free Azure account before you begin.
  • Download Postman or use Postman online free version.
  • Generate Access Token with Power BI Administrator permission. This article help you understand what Power BI Administrator role is, and how to assign a user to Power BI Administrator role. This article will help you better understand Power BI Administrator role.  

 

Steps

1. Download Postman and import Postman request examples: API request examples 

2. Log into Power BI website with admin account, press F12 to open browser console, then enter the following command in the browser console, past the access token to your clipboard.  

 

 

 copy(powerBIAccessToken)

 

 

3. Paste your access token into postman collection in Authorization tab with “Bearer Token” Type.

AmberData_3-1686024512004.png

4. In step 1, fill in the workspace ids in the body of post requests with JSON format, then save and send the request: 

5. Then you will get response body like below, please note down the id as request id:

{

    "id": "******myrequestid",

    "createdDateTime": "2023-06-06T02:21:57.8482466Z",

    "status": "NotStarted"

}

6. In step 2, use your request id to replace <myrequestid> in the GET API.

7. In step 2, use https://api.powerbi.com/v1.0/myorg/capacities to get Power BI location. And replace your location to the following Location parameter.

https://*****.analysis.windows.net/v1.0/myorg/admin/workspaces/scanStatus/<myrequestid>

Please make sure the status is "Succeeded". If not, please wait for some time and resend the Get request.

AmberData_4-1686024512028.png

 

8. If you can get the "Succeeded" status in step 2, let’s move to step 3, after replaced location and request id, if the GET request in step 3 got 200 status respond, you will see the output of the Power BI content.

AmberData_5-1686024512046.png

 

Co-Authors
Version history
Last update:
‎Jun 06 2023 08:55 AM
Updated by: