cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Power BI Rest API continuation token is corrupted

Hi,
When running the Get Activity Events API Call, it returns a few activities and a continuation token. When trying to use the token to contionue the call, i get the following error: 

 

{

  "error": {

    "code""InvalidRequest",

    "message""Looks like that continuation token is corrupted. Replace it with the same continuation token that was sent back in the previous API response, and try again"

  }
}

I get this error when i have single quotations around the token. if i do not have any quotations i get the following error:

{
  "error": {
    "code": "BadRequest",
    "message": "Bad Request",
    "details": [
      {
        "message": "Expected literal type token but found token 'LDIwMjAtMDQtMDZUMDA6MDA6MDEsMjAyMC0wNC0wNlQyMzo1OTo1OSwxLCw'.",
        "target": "continuationToken"
      }
    ]
  }
}



1 ACCEPTED SOLUTION

Hi @liljath 

Yes, yous should not use the continuationToken, but the continuationUri, and use it to make a new get request. 

The documentation for this API is poor and outdated, unfortunately.

Let me know if you need further assistance.

View solution in original post

5 REPLIES 5
New Member

Hi,

I got the same error when building PowerAutomate Flow to retreive PBI activity events using custom connector based on Swagger https://github.com/microsoft/powerbi-rest-api-specs/blob/master/swagger.json

Turned out that the continuation token needs to be decoded for the 'Returns a list of audit activity events for a tenant' step to work properly.

In MS Flow - Parse the continuation token from Json, then decode with function decodeUriComponent() and finally wrap the expression in single quotes. 

eg. 'decodeUriComponent(body('Parse_JSON')?['continuationToken'])'

 

PowerShell does it behind the scene like this:

https://github.com/microsoft/powerbi-powershell/blob/master/src/Modules/Admin/Commands.Admin/GetPowe...

...

 string formattedContinuationToken = $"'{WebUtility.UrlDecode(response.ContinuationToken)}'";
response = client.Admin.GetPowerBIActivityEvents(null, null, formattedContinuationToken, null);

...

New Member

Hi,

 

Did you manage to get this fixed?

I have tried using the token but keep getting the same errors as you. I have put single quotes around the token, double quotes as well.

 

Cheers,

liljath

Hi @liljath 

Yes, yous should not use the continuationToken, but the continuationUri, and use it to make a new get request. 

The documentation for this API is poor and outdated, unfortunately.

Let me know if you need further assistance.

View solution in original post

Hi @oliversvane ,

 

Thank you for this 🙂 it's been driving me crazy lol

Do you know if it possible to use the powerbiclient from the package Microsoft.PowerBI.Api?

I am using pbiClient.Admin.GetActivityEvents(startdate, enddate) to get the first call but when I put the continuationtoken in there it just doesn't work.

I was thinking maybe something like powerbiclient.httpclient ... but have tried this with a 403 result.

Do you call the api with this client or a normal httpclient?

 

cheers,

liljath

Hi @liljath 

 

I am currently using Power Automate to pull the data one a day. You can read more about the general idea here:
https://medium.com/@Konstantinos_Ioannou/refresh-powerbi-dataset-with-microsoft-flow-73836c727c33
It is an old article showing you how to refresh a dataset uding Power Automate (this article is from before it was possible with a simple connector)

If you are using Powershell you can use the PBI Cmdlets (read more here). Once that is installed you can run requests from Powershell. Here is an example, where the logs are saved in .json files for each individual day:

Login-PowerBI
$date = [datetime]'07/10/2020'

$array =
do {
$date.ToString('yyyy-MM-dd')
$date2 =(Get-Date $date -Format 'yyyy-MM-dd')
$begindate=-join($date2,'T00:00:00')
$enddate =-join($date2,'T23:59:59')
$paths =-join('C:\audit\',$date2,'.json')
$activities = Get-PowerBIActivityEvent -StartDateTime $begindate -EndDateTime $enddate | Out-File $paths
$date = $date.AddDays(1)
}

until ($date -gt [datetime]'07/14/2020')

 

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.