Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I'm trying to use a powershell script to fetch all workspaces using:
Invoke-PowerBIRestMethod -Url "/admin/groups?%24top=3000" -Method Get | ConvertFrom-Json
Then checking for each group received for reports inside, using:
Invoke-PowerBiRestMethod -url ("admin/groups/" + $group.id + "/reports") -method get | ConvertFrom-Json
I was then unable to find a method to retrieve the pbix files using the API, so I resorted to:
Export-PowerBiReport -ID $report.id -OutFile ($v_pbixfilepath + $group.name + "\" + $report.name + ".pbix")
Which just then leads me to this error:
Export-PowerBiReport : Operation returned an invalid status code 'NotFound'
This may be because my user, a global admin, is not introduced in the workspaces where the reports are. However, I've tried to use an automatic way to add the user by the Add-UserAsAdmin method, but I get a 400 Bad Request. This can be due to my payload, but some workspaces work.
I'm stumped and I'd like to know if I'm approaching this correctly or there's no way of doing this through the API and should do it manually/other way instead. Thank you.
Solved! Go to Solution.
Couldn't get the files through admin, however using this API call (which I missed) allowed me to get the reports within that workspace. However, the user needs to be in the workspace.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreportingroup
Couldn't get the files through admin, however using this API call (which I missed) allowed me to get the reports within that workspace. However, the user needs to be in the workspace.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreportingroup