<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Power BI Rest API continuation token is corrupted in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224419#M24754</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently using Power Automate to pull the data one a day. You can read more about the general idea here:&lt;BR /&gt;&lt;A href="https://medium.com/@Konstantinos_Ioannou/refresh-powerbi-dataset-with-microsoft-flow-73836c727c33" target="_blank"&gt;https://medium.com/@Konstantinos_Ioannou/refresh-powerbi-dataset-with-microsoft-flow-73836c727c33&lt;/A&gt;&lt;BR /&gt;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)&lt;BR /&gt;&lt;BR /&gt;If you are using Powershell you can use the PBI Cmdlets (read more &lt;A href="https://docs.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps" target="_self"&gt;here&lt;/A&gt;). 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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;Login-PowerBI&lt;BR /&gt;$date = [datetime]'07/10/2020'&lt;BR /&gt;&lt;BR /&gt;$array = &lt;BR /&gt;do {&lt;BR /&gt;$date.ToString('yyyy-MM-dd')&lt;BR /&gt;$date2 =(Get-Date $date -Format 'yyyy-MM-dd')&lt;BR /&gt;$begindate=-join($date2,'T00:00:00')&lt;BR /&gt;$enddate =-join($date2,'T23:59:59')&lt;BR /&gt;$paths =-join('C:\audit\',$date2,'.json')&lt;BR /&gt;$activities = Get-PowerBIActivityEvent -StartDateTime $begindate -EndDateTime $enddate | Out-File $paths&lt;BR /&gt;$date = $date.AddDays(1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;until ($date -gt [datetime]'07/14/2020')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jul 2020 10:50:46 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-07-15T10:50:46Z</dc:date>
    <item>
      <title>Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1012533#M22994</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;When running the&amp;nbsp;Get Activity Events API Call, it returns a few activities and a&amp;nbsp;continuation token. When trying to use the token to contionue the call, i get the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"error"&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"code"&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"InvalidRequest"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"message"&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"Looks&amp;nbsp;like&amp;nbsp;that&amp;nbsp;continuation&amp;nbsp;token&amp;nbsp;is&amp;nbsp;corrupted.&amp;nbsp;Replace&amp;nbsp;it&amp;nbsp;with&amp;nbsp;the&amp;nbsp;same&amp;nbsp;continuation&amp;nbsp;token&amp;nbsp;that&amp;nbsp;was&amp;nbsp;sent&amp;nbsp;back&amp;nbsp;in&amp;nbsp;the&amp;nbsp;previous&amp;nbsp;API&amp;nbsp;response,&amp;nbsp;and&amp;nbsp;try&amp;nbsp;again"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;I get this error when i have single quotations around the token. if i do not have any quotations i get the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;{
  &lt;SPAN class="hljs-attr"&gt;"error"&lt;/SPAN&gt;: {
    &lt;SPAN class="hljs-attr"&gt;"code"&lt;/SPAN&gt;: &lt;SPAN class="hljs-string"&gt;"BadRequest"&lt;/SPAN&gt;,
    &lt;SPAN class="hljs-attr"&gt;"message"&lt;/SPAN&gt;: &lt;SPAN class="hljs-string"&gt;"Bad Request"&lt;/SPAN&gt;,
    &lt;SPAN class="hljs-attr"&gt;"details"&lt;/SPAN&gt;: [
      {
        &lt;SPAN class="hljs-attr"&gt;"message"&lt;/SPAN&gt;: &lt;SPAN class="hljs-string"&gt;"Expected literal type token but found token 'LDIwMjAtMDQtMDZUMDA6MDA6MDEsMjAyMC0wNC0wNlQyMzo1OTo1OSwxLCw'."&lt;/SPAN&gt;,
        &lt;SPAN class="hljs-attr"&gt;"target"&lt;/SPAN&gt;: &lt;SPAN class="hljs-string"&gt;"continuationToken"&lt;/SPAN&gt;
      }
    ]
  }
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 07 Apr 2020 12:14:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1012533#M22994</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-07T12:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1222206#M24730</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you manage to get this fixed?&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;liljath&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:50:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1222206#M24730</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-14T16:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224289#M24751</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Yes, yous should not use the&amp;nbsp;&lt;SPAN&gt;continuationToken, but the&amp;nbsp;continuationUri, and use it to make a new get request.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The documentation for this API is poor and outdated, unfortunately.&lt;BR /&gt;&lt;BR /&gt;Let me know if you need further assistance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 10:02:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224289#M24751</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-15T10:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224327#M24752</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; it's been driving me crazy lol&lt;/P&gt;&lt;P&gt;Do you know if it possible to use the powerbiclient from the package Microsoft.PowerBI.Api?&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp;pbiClient.Admin.GetActivityEvents(startdate, enddate) to get the first call but when I put the continuationtoken in there it just doesn't work.&lt;/P&gt;&lt;P&gt;I was thinking maybe something like powerbiclient.httpclient ... but have tried this with a 403 result.&lt;/P&gt;&lt;P&gt;Do you call the api with this client or a normal httpclient?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;liljath&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 10:15:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224327#M24752</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-15T10:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224419#M24754</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently using Power Automate to pull the data one a day. You can read more about the general idea here:&lt;BR /&gt;&lt;A href="https://medium.com/@Konstantinos_Ioannou/refresh-powerbi-dataset-with-microsoft-flow-73836c727c33" target="_blank"&gt;https://medium.com/@Konstantinos_Ioannou/refresh-powerbi-dataset-with-microsoft-flow-73836c727c33&lt;/A&gt;&lt;BR /&gt;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)&lt;BR /&gt;&lt;BR /&gt;If you are using Powershell you can use the PBI Cmdlets (read more &lt;A href="https://docs.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps" target="_self"&gt;here&lt;/A&gt;). 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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;Login-PowerBI&lt;BR /&gt;$date = [datetime]'07/10/2020'&lt;BR /&gt;&lt;BR /&gt;$array = &lt;BR /&gt;do {&lt;BR /&gt;$date.ToString('yyyy-MM-dd')&lt;BR /&gt;$date2 =(Get-Date $date -Format 'yyyy-MM-dd')&lt;BR /&gt;$begindate=-join($date2,'T00:00:00')&lt;BR /&gt;$enddate =-join($date2,'T23:59:59')&lt;BR /&gt;$paths =-join('C:\audit\',$date2,'.json')&lt;BR /&gt;$activities = Get-PowerBIActivityEvent -StartDateTime $begindate -EndDateTime $enddate | Out-File $paths&lt;BR /&gt;$date = $date.AddDays(1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;until ($date -gt [datetime]'07/14/2020')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 10:50:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1224419#M24754</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-15T10:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1453539#M26237</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I got the same error when building PowerAutomate Flow to retreive PBI activity events using custom connector based on Swagger &lt;A href="https://github.com/microsoft/powerbi-rest-api-specs/blob/master/swagger.json" target="_blank"&gt;https://github.com/microsoft/powerbi-rest-api-specs/blob/master/swagger.json&lt;/A&gt; .&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;In MS Flow - Parse the continuation token from Json, then decode with function&amp;nbsp;decodeUriComponent() and finally wrap the expression in single quotes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg. 'decodeUriComponent(body('Parse_JSON')?['continuationToken'])'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PowerShell does it behind the scene like this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/microsoft/powerbi-powershell/blob/master/src/Modules/Admin/Commands.Admin/GetPowerBIActivityEvent.cs" target="_blank"&gt;https://github.com/microsoft/powerbi-powershell/blob/master/src/Modules/Admin/Commands.Admin/GetPowerBIActivityEvent.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;string formattedContinuationToken = $"'{WebUtility.UrlDecode(response.ContinuationToken)}'";&lt;BR /&gt;response = client.Admin.GetPowerBIActivityEvents(null, null, formattedContinuationToken, null);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;</description>
      <pubDate>Sat, 24 Oct 2020 21:10:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/1453539#M26237</guid>
      <dc:creator>maril</dc:creator>
      <dc:date>2020-10-24T21:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/2579950#M36717</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having the same issue with the SDK and have been unable to figure out how to use the continuationUri that you mentioned with the SDK.&amp;nbsp; &amp;nbsp;The SDK works quite well for all of the various pieces of data that I am consuming, and it even works fine for activities too provided I ignore the continuation token.&amp;nbsp; Every attempt to use that so far has failed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have an example of using the continuationUri with the SDK specifically?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 10:47:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/2579950#M36717</guid>
      <dc:creator>allenwilson</dc:creator>
      <dc:date>2022-06-15T10:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Rest API continuation token is corrupted</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/2676508#M37686</link>
      <description>&lt;P&gt;For anyone who runs across this thread later on, I wanted to share a solution.&amp;nbsp; I never got this to work with the SDK - as I believe there is a bug in the way it escapes/handles the continuationToken.&amp;nbsp; But, to bypass the SDK and use the API directly was straightforward, and I was able to reuse my existing (Service Principal) Access Token, which was great.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a code example that works - I hope it helps someone else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;public static JObject GetActivityEvents(string startDateTime = default, string endDateTime = default, string continuationToken = default)&lt;BR /&gt;{&lt;BR /&gt;// Note: This function is necessary because of the bug in the SDK which causes use of the continuationToken to throw an error&lt;BR /&gt;// To work around this issue, the function was created to grab next records. Once SDK is fixed, this can be eliminated.&lt;/P&gt;&lt;P&gt;// Get HttpClient&lt;BR /&gt;var accessToken = AadService.GetAccessToken();&lt;BR /&gt;HttpClient client = new HttpClient();&lt;BR /&gt;client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);&lt;/P&gt;&lt;P&gt;// Set Url&lt;BR /&gt;string serviceUrl = string.Concat(ConfigSettings.PbiServiceApiUri, "v1.0/myorg/admin/activityevents");&lt;BR /&gt;serviceUrl += (string.IsNullOrEmpty(continuationToken))&lt;BR /&gt;? string.Concat("?startDateTime=", startDateTime, "&amp;amp;endDateTime=", endDateTime, "&amp;amp;$filter=Activity eq 'viewreport'")&lt;BR /&gt;: string.Concat("?continuationToken='", continuationToken, "'");&lt;/P&gt;&lt;P&gt;// Get Response&lt;BR /&gt;HttpResponseMessage response = client.GetAsync(serviceUrl).Result;&lt;/P&gt;&lt;P&gt;//If Unsuccessful, raise exception&lt;BR /&gt;response.EnsureSuccessStatusCode();&lt;/P&gt;&lt;P&gt;// Return results&lt;BR /&gt;string content = response.Content.ReadAsStringAsync().Result;&lt;BR /&gt;return JObject.Parse(content);&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 20:13:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-Rest-API-continuation-token-is-corrupted/m-p/2676508#M37686</guid>
      <dc:creator>allenwilson</dc:creator>
      <dc:date>2022-08-02T20:13:40Z</dc:date>
    </item>
  </channel>
</rss>

