Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
To whom it may concern:
I've tried following the documentation at Admin - Groups GetGroupsAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Learn. Granted I've built a powershell and have been using it for the other "admin API". When it comes to this one, it will not work.
Partial code.
# Authenticate with Azure AD using the App Registration
$uri = "https://api.powerbi.com/v1.0/myorg/admin/groups?$top=100"
$headers = @{
Authorization = "Bearer $accessToken"
}
# Call the Power BI REST API to retrieve a list of dataflows
$response = Invoke-PowerRestMethod -Url $uri -Method Get -headers $headers
$completeListOfActivityEvents = @()
$completeListOfActivityEvents += $response.value
$continuationToken = $response.continuationToken
$continuationUri = $response.continuationUri
while ($ContinuationToken -ne $null)
{
$response = Invoke-RestMethod -Uri $continuationUri -Method get -Headers $headers
$continuationUri = $response.continuationUri
$continuationToken = $response.continuationToken
$completeListOfActivityEvents += $response.value
}
$completeListOfActivityEvents | Export-Csv -LiteralPath $Path
Solved! Go to Solution.
run a second call
$topn="%24top=5000"
$skip="%24skip=5000"
$Url = "https://api.powerbi.com/v1.0/myorg/admin/groups?$topn&$skip"
$uri = "https://api.powerbi.com/v1.0/myorg/admin/groups?$top=100"
...
$response = Invoke-PowerRestMethod -Url $uri -Method Get -headers $headers
Wrong uri format. If you use Invoke-PowerBIRestMethod (not Invoke-PowerRestMethod) then you are supposed to supply a relative URI "admin/groups/..."
Thanks for the reply.
I've not been using - Invoke-PowerBIRestMethod (MicrosoftPowerBIMgmt.Profile) | Microsoft Learn.
I've been using - Invoke-RestMethod -Uri $Url -Method get -Headers $headers
I did get it to work after going back to my original. The issue, is I have 9424 workspaces and need them all, not just the 5000.
use $top and $skip
this works for 5000. How to get the others is the questions.
CODE.
$authResult = Invoke-WebRequest -Uri $authUrl -Method POST -Body $body
$accessToken = ($authResult.Content | ConvertFrom-Json).access_token
# Call the Power BI REST API to retrieve a list of dataflows
$topn="%24top=5000"
$Url = "https://api.powerbi.com/v1.0/myorg/admin/groups?$topn"
$headers = @{
Authorization = "Bearer $accessToken"
}
$response = Invoke-RestMethod -Uri $Url -Method get -Headers $headers
$completeListOfActivityEvents = @()
$completeListOfActivityEvents += $response.value
$continuationToken = $response.continuationToken
$continuationUri = $response.continuationUri
while ($ContinuationToken -ne $null)
{
$response = Invoke-RestMethod -Uri $continuationUri -Method get -Headers $headers
$continuationUri = $response.continuationUri
$continuationToken = $response.continuationToken
$completeListOfActivityEvents += $response.value
}
END CODE
run a second call
$topn="%24top=5000"
$skip="%24skip=5000"
$Url = "https://api.powerbi.com/v1.0/myorg/admin/groups?$topn&$skip"
Thanks for the assist.
I was able to get all the workspaces by performing two calls.
Thanks.
I have the documentation. However, I don't know how to write it in powershell using skip and top. Please note, I'm a beginner when it comes to API.
User | Count |
---|---|
8 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |