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.