Forum Discussion
Download report from "My Workspace" using REST API?
Hi,
Is there a way to download reports from "My Workspace" using REST API? What would be the exact syntax in PowerShell?
If I authenticate at Connect-PowerBIServiceAccount with my user, I can list all workspaces that I have access to with Get-PowerBIWorkspace -All (-All just turns off a top 100 filter) but my "My Workspace" is not included. And trying to list the reports in my workspace with a /me/ Url instead of a workspace ID (like https://api.powerbi.com/v1.0/myorg/groups/me/reports) returns 403 (Forbidden). I also looked up the workspace ID of My Workspace in a tenant scan, but still get 403 (Frobidden).
How can I download with my credentials reports from my workspace using PowerShell?
If there is no way to do this in PowerShell but there would be a way in Power Automate, please let me know, this might be a workaround.
Kind regards,
Martin
Hi Martin_D
I understand that the implementation did not work as expected.Currently, there isn't a specific documented or undocumented API for downloading reports from "My Workspace".
- Power BI APIs are generally more optimized for organizational workspaces rather than My Workspace. This can cause unexpected issues or limited functionality when trying to automate tasks for reports stored in My Workspace.
- Consider migrating the report to an organizational workspace to potentially resolve this issue.
If the issue persists, please consider raising a Microsoft support ticket for further assistance.Below is the link to create Microsoft Support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
If my response has resolved your query, please mark it as the Accepted Solution to help others. Additionally, I would appreciate a 'Kudos' if you found my response helpful.
Thank You.
15 Replies
- mariussve1Solution Sage
Hi,
Is there an option to use the REST API? You can use this both in PowerShell and, for that matter, in Power Automate.
If you’re using PowerShell, you can utilize
Invoke-RestMethod:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.4Here’s some documentation on the API:
https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-reportIf this is just a one-time task, you can also use the Try It function:
https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-report - v-karpurapudCommunity Support
Hi Martin_D
Thanks for reaching out to Microsoft Fabric Community Forum.
Unfortunately, REST API and PowerShell do not provide direct access to "My Workspace" for downloading reports due to the way permissions and access are managed.
However, Power Automate can be used as a workaround to export reports from "My Workspace.
- To do this, create a new flow in Power Automate and select the appropriate trigger.
- Next, add the "Export to File for Power BI Reports" action, select "My Workspace," and choose the report you want to export. Then, select the export format (e.g., PDF).
- Finally, add an action to send an email with the exported file as an attachment and test the flow to ensure it exports and saves the file correctly.
If you find this post helpful, please mark it as an "Accept as Solution" and give a KUDOS.
Thank You.
- mariussve1Solution Sage
Are you sure about that? According to the API documentation, there are two different ones, where one provides access to My Workspace, and the other does not:
GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export
Exports the specified report from My workspace to a Power BI .pbix or .rdl file.
GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/Export
Exports the specified report from the specified workspace to a Power BI .pbix or .rdl file.
You can run any REST API from PowerShell, for example, usingInvoke-RestMethod.- v-karpurapudCommunity Support
Hi mariussve1
While it is technically correct that the first API endpoint can be used to access "My Workspace", there are practical challenges and limitations:- "My Workspace" is associated with the personal scope of the authenticated user. To access the endpoint successfully, the account used for authentication must have sufficient permissions and valid access tokens with the correct scopes.
- 403 Forbidden Errors: These errors typically occur if the authentication does not have the necessary permissions or scope for accessing personal workspaces.
- This might occur when using service principals or accounts that are not explicitly authorized to access "My Workspace."
- Invoke-RestMethod can indeed be used to call REST API endpoints, but the key challenge remains obtaining the appropriate access token and ensuring the request headers include the required authorization details.
- Martin_DSolution Sage
Hi v-karpurapud
Thank you for suggesting Power Automaten. Since the use case is creating a backup of the pbix file, any other file format is not useful.
Is there also a way to down the pbix file from My Workspace using Power Automate?
Kind regards,
Martin
- v-karpurapudCommunity Support
Hi Martin_D
To download a PBIX file from "My Workspace" using Power Automate, please follow these steps:1. Create a new flow in Power Automate and add a trigger to initiate the flow.
2. Include the "HTTP" action to make an API call and configure it as follows:
- Method: GET
- URI: https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export
- Headers:
- Authorization: Bearer {access_token}
- Content-Type: application/json
- Replace {reportId} with the ID of the report you wish to export.
3. Add an action to save the exported file to a designated location (e.g., OneDrive, SharePoint, or send it via email).
Ensure you have the necessary permissions and access tokens to perform this action. This method should enable you to download the PBIX file from "My Workspace."
If you find this post helpful, please mark it as an "Accept as Solution" and give a KUDOS.
Thank You.
- v-karpurapudCommunity Support
Hi Martin_D
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
- v-karpurapudCommunity Support
Hi Martin_D
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you. - v-karpurapudCommunity Support
Hi Martin_D
Hope you are doing well!
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.- Martin_DSolution Sage
Hi v-karpurapud ,
The only remaining option I currently See could be a service principal with Admin consent. Since I don't have such service principal, I cannot verify. Do you have any chance to verify this?
Thank you!
Kind regards,
Martin
- v-karpurapudCommunity Support
Hello Martin_D
We understand your concerns about downloading the report from "My Workspace" using the REST API.We sincerely regrest for the inconvenience and acknowledge your requirements. Unfortunately, we don't have a service principal to verify this. As I suggested in my earlier response,
raising a support ticket with Microsoft for further assistance might resolve the issue.
If you find this post helpful, please mark it as an "Accept as Solution" and give a KUDOS.
Thank you!