Forum Discussion
Export to file - Power BI Report with Filters / Parameters
- Anonymous6 years ago
Hi Anonymous
The documentation currently states that the Bookmark name (whilst accepted as a parameter) is not currently available.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofile#pagebookmark
The only way to update output via bookmarks, is to pass in the bookmark state.
And the only way that you can get the bookmark state (that I know of) is via the JavaScript API. https://github.com/Microsoft/PowerBI-JavaScript/wiki/Bookmarks#capture-and-get-a-current-view-as-a-bookmark-object-and-apply-it-back-on-the-current-session
The 'capture' function will return a single string value that represents the bookmark state. You can then pass this into the API.
This is far from ideal... but I think the export API endpoint is still under preview, so will likely change quite a bit.
The idea I raised for adding missing functionality to this API has also moved into the planned phase. So hopefully, it won't be too long before these missing features are available. https://ideas.powerbi.com/ideas/idea/?ideaid=0e056f7d-34b4-4778-974f-929228effcdd
Cheers, Matt
I went looking at options for this... The only oneI can find (the one I was previously experimenting with) was via the JavaScript embedding API. https://github.com/Microsoft/PowerBI-JavaScript/wiki/Bookmarks
The section at the end shows how to capture a bookmark programatically. The resulting object then holds the bookmark state.
// Capture the current view
let capturedBookmark = report.bookmarksManager.capture();
// Applied previously captured state
report.bookmarksManager.applyState(capturedBookmark.state);
I tried to work out how this state object was structured, in the hope I could dynamically create it in C#... but I didn't get very far.
As I mentioned before... If you only have a small number of filters and bookmark states that you need to capture, then you could use this method to fetch those states and reuse them as many times as you like. But as soon as you want to do anything really dynamic... you hit a bit of a blocker.
I am keeping my fingers crossed for quick updates to the API to add the parameters. 😀
Looks like the Idea has moved to 'Under Review'.
https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/40060261-add-filter-options-to-the-export-file-api
I will update this thread as things progress.
Feel free to go and up-vote! 😀
- Anonymous6 years agoNot applicable
Anonymous
I am using the REST APIs for ExportToFile in my Power Automate flow.
I can export the PDF with no issues in a normal use case, but next I want to try out exporting a PDF with a particular bookmark.
Use case is - I have 5 user groups and I will create 5 bookmarks (one for each).
Will send the PDF in an email to each of them as per their individual bookmarks.
However, when I try to put the bookmark name in my flow, it doesn't work.
Here is how my flow looks -
The error I get is -
{"error": {"code": "BadRequest","message": "Bad Request","details": [{"message": "Error converting value \"Group1_bookmark\" to type 'Microsoft.PowerBI.ServiceContracts.Api.V1.PageBookmark'. Path 'powerBIReportConfiguration.defaultBookmark', line 1, position 74.","target": "request.powerBIReportConfiguration.defaultBookmark"}]}}Appreciate if you can provide any inputs in case you have any ideas around this use case?Regards- Anonymous6 years agoNot applicable
Hi Anonymous
The documentation currently states that the Bookmark name (whilst accepted as a parameter) is not currently available.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofile#pagebookmark
The only way to update output via bookmarks, is to pass in the bookmark state.
And the only way that you can get the bookmark state (that I know of) is via the JavaScript API. https://github.com/Microsoft/PowerBI-JavaScript/wiki/Bookmarks#capture-and-get-a-current-view-as-a-bookmark-object-and-apply-it-back-on-the-current-session
The 'capture' function will return a single string value that represents the bookmark state. You can then pass this into the API.
This is far from ideal... but I think the export API endpoint is still under preview, so will likely change quite a bit.
The idea I raised for adding missing functionality to this API has also moved into the planned phase. So hopefully, it won't be too long before these missing features are available. https://ideas.powerbi.com/ideas/idea/?ideaid=0e056f7d-34b4-4778-974f-929228effcdd
Cheers, Matt- Anonymous6 years agoNot applicable
Anonymous
Thanks for providing the details which I didn't know about.
Hoping that this functionality is added soon.
I have voted the idea.
Regards