Forum Discussion
"Get Activity Events" REST API only returns 1 entry at a time
- 2 years ago
Hi all
Found a solution ... and documenting it for posternity. I tried to go all the way and see what happens if I keep using the continuation token with a while loop.
$url_get_logs = "https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='2023-09-01T00:00:00'&endDateTime='2023-09-01T09:59:59'" $response = Invoke-RestMethod -Uri $url_get_logs -Method get -Headers $postParams $completeListOfActivityEvents = @() $completeListOfActivityEvents += $response.ActivityEventEntities $continuationToken = $response.continuationToken $continuationUri = $response.continuationUri while ($ContinuationToken -ne $null) { $response = Invoke-RestMethod -Uri $continuationUri -Method get -Headers $postParams $continuationUri = $response.continuationUri $continuationToken = $response.continuationToken $completeListOfActivityEvents += $response.ActivityEventEntities }Turns out this REST API is quite whimsical. Very stingy at the beginning – and then it starts going. It gave me 1 entry, then another 1, then 4, then 10, then 33, then 523, ...
So everything ok at the end ... but I feel like it would be good if this behaviour was documented.
Thanks
Alex
Hi @v-yiuran-msft
Thanks for your answer.
- I think the query parameters are correct. I am trying to get the events from a whole day. There is more than 1 entry per day.
- I'm not sure about the continuation token: the problem is alreay with the very first request. I would expect that the first request gives me 5000-10000 entries.
- I tried using different days. On one of the days I got 2 entries instead of 1, but still ...
- I also tried the PowerBI commandlet (Get-PowerBIActivityEvent) this works great. However, I would like to use the REST API with a service principal, so the commandlet is not an option for me.
Any other ideas about the REST API?
I was also wondering if it could have to do with the scope of the token. I am using:
scope='https://analysis.windows.net/powerbi/api/.default'Thanks
Alex