Export chart data API
If the visual header is enabled on a Power BI chart visual, users are able to export chart data to CSV or Excel by selecting the 'More Options' menu option followed by 'Export chart'.
In order for PowerTester to perform the export, it needs authorization to access your reports. There are two ways to provide authorization to PowerTester to access your reports: 1) provide a connection guid that has been authorized with a Power BI user inside of PowerTester, 2) provide a bearer token generated with the Report.Read.All scope.
Export chart using an existing connection
As mentioned above, this method requires an existing connection in PowerTester. To create a connection, see our article on how to create a connection. Once the connection has been created and authorized, it can be used to authenticate with Power BI.
In order to call the Export Chart Data API, you need a few pieces of information:
- The connection guid
- Your account guid
- Your API key
- The guid of the workspace or app the report is in
- The alt-text of the chart you'd like to export
- The name of the report
The API key and account guid will be provided to you by the PowerTester team. The connection guid can be retrieved from the GetConnections API as shown below.
The connection guid
The connection guid can be retrieved using your account guid and API key. Simply call the GetConnections API passing in your account guid to get a list of all connections under your account along with their guids.
The workspace guid
To get the guid of the workspace, navigate to your report and copy the guid before the '/reports/' section in the URL.
In order for PowerTester to identify the chart, the chart needs to have its alt-text property set to a value that is unique on that report page. See our article on alt-text for more details.
Putting it all together
Your request should look something like this:
Send this to the API and the response you receive will be a byte array. Save this to a file as a .xlsx and open it in Excel to receive your data! See the API docs for more details.
Export chart using user-provided token
This API is similar to the one above except it doesn't require a connection object in PowerTester, meaning if you would like to perform the authentication as part of your pipeline rather than in PowerTester, you only need pass the bearer token through to PowerTester and you'll still be able to export your data.
To be able to export the chart data, your token will need to have been granted the Report.Read.All scope.
The request will look something like this:
See the API docs for more details.