Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
adeeln
Post Patron
Post Patron

Export to file API with Current Values

Hi Experts,

I'm working on Power BI Embedded API. I've been embedded in a report on my web application.

Now my client has a requirement to do export in PDF feature with the default state/current values/selected values/filtered values of the report.

Example: The same scenario like, If we see on Power BI service open any report go to File > Export to PDF as shown in the below image

 

export file.png

 

a pop-up will come to ask you to export with current values (means filters/selection that you've applied on the report) or default values (default state of report nothing selected). So in case of current values Power BI service export the report as expected behavior, with filtered data of the report.

 

Export with Current Values.png

 

But in API I couldn't see this option. I'm following this link to export the power bi embedded report to PDF.

https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup

But I'm unable to see current values options in API.

Please help how can I do export report through API with current values as shown in the above images.

Thanks

 

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @adeeln 

 

The option won't prompt automatically when you use the API, did you specify the export content in the JSON body?

https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup#powerbireportexportco...

Note that:

You can use the exportToFile API to programmatically export a report in a specific state, after applying filters to it. This is done using Bookmarks capabilities. To export a report using bookmarks, use the bookmarks JavaScript API.

For example, you can use the bookmark's capturedBookmark.state method to capture the changes a specific user made to a report, and then export it in its current state.

Personal bookmarks and persistent filters are not supported.

 

Here're blogs for your reference:

https://blog.crossjoin.co.uk/2020/04/25/calling-the-power-bi-export-api-from-power-automate-part-1-c...

https://blog.crossjoin.co.uk/2020/04/27/calling-the-power-bi-export-api-from-power-automate-part-2-c...

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

4 REPLIES 4
shubh43
Regular Visitor

Hi,

 

I'm trying below mentioned request for export report with current values but API is throwing error, I appreciate if somebody help me to solved this, i need to fix this ASAP.

 

API Endpoint:

https://api.powerbi.com/v1.0/myorg/groups/{groupid}/reports/{reportid}/ExportTo

 

Request:

{
"format": "PDF",
"powerBIReportConfiguration": {
"settings": {
"locale": "en-US",
"excludeHiddenPages": "false"
},
"defaultBookmark": "H4sIAAAAAAAAA+1deW8bR5b/KgSB3cwASlD3.."
}
}


Response:
{
"error": {
"code": "BadRequest",
"message": "Bad Request",
"details": [
{
"message": "Error converting value \"H4sIAAAAAAAAA+1deW8bR5...",
"target": "request.powerBIReportConfiguration.defaultBookmark"
}
]
}
}

AbdelSolis
Frequent Visitor

Hi, guys.

I'm trying to export to a pdf file a power bi embedded report in a custom app with the current values of the report but when I use this function: let capturedBookmark = report.bookmarksManager.capture();  this error shows to me:

message: "captureBookmarkFailed", detailedMessage: "Invalid bookmark request", level: 3. 

So I was wondering if anybody had the same error and how did you solve it?

 

Thanks in advance.

v-diye-msft
Community Support
Community Support

Hi @adeeln 

 

The option won't prompt automatically when you use the API, did you specify the export content in the JSON body?

https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup#powerbireportexportco...

Note that:

You can use the exportToFile API to programmatically export a report in a specific state, after applying filters to it. This is done using Bookmarks capabilities. To export a report using bookmarks, use the bookmarks JavaScript API.

For example, you can use the bookmark's capturedBookmark.state method to capture the changes a specific user made to a report, and then export it in its current state.

Personal bookmarks and persistent filters are not supported.

 

Here're blogs for your reference:

https://blog.crossjoin.co.uk/2020/04/25/calling-the-power-bi-export-api-from-power-automate-part-1-c...

https://blog.crossjoin.co.uk/2020/04/27/calling-the-power-bi-export-api-from-power-automate-part-2-c...

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Thanks @v-diye-msft, pretty much clear solution you've provided.

One more question, Is embedded Q&A supports ExportToFile?

Can you also look into these Posts, please?

https://community.powerbi.com/t5/Developer/Export-embedded-Q-amp-A-results-to-PDF/m-p/1378432
https://community.powerbi.com/t5/Developer/Export-embedded-Q-amp-A-results-to-PDF/m-p/1371667#M25738

 

Thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors