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

Problem when calling Dataset refresh API

Hi all,

 

I recently created a Function App to call dataset refresh API. The first call succeeded, but every calls after that raised 400 Bad Request.

h1.png

 

What is the reason of this error, and how can I fix it?

 

Thanks,

 

Diem

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft Eric_Zhang
Microsoft

Re: Problem when calling Dataset refresh API


@nphdiem95 wrote:

Hi all,

 

I recently created a Function App to call dataset refresh API. The first call succeeded, but every calls after that raised 400 Bad Request.

h1.png

 

What is the reason of this error, and how can I fix it?

 

Thanks,

 

Diem


@nphdiem95

Instead of the simple 400 error, try to output the details error message with try catch block.

 

$groupsPath ="dc581184-a209-463b-8446-5432f16b6c15" 
$datasetID = "1f6285a5-7b98-4758-8f81-77b7ae5637d6"

$headers = @{}
$headers.Add("Authorization","Bearer eyJxxxxxxxxxxxxxxQvNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3LyIsImlhdCI6MTUwNTI3MDA5NSwibmJmIjoxNTA1MjcwMDk1LCJleHAiOjE1MDUyNzM5OTUsImFjciI6IjEiLCJhaW8iOiJZMlZnWUxEOFhTdkt6bXEyc09HSDFINmR4U1p6VXJRVFRrMTIyMjcrYVZWZnZQTVI5dHNBIiwiYW1yIjpbInB3ZCJdLCJhcHBpZCI6IjQ5ZGYxYmM3LWRiNjgtNGZiNC05MWMwLTZkOTNmNzcwZDFhNCIsImFwcGlkYWNyIjoiMCIsImZhbWlseV9uYW1lIjoiWmhhbmciLCJnaXZlbl9uYW1lIjoiRXJpYyIsImlwYWRkciI6IjE2Ny4yMjAuMjU1LjgiLCJuYW1lIjoiRXJpYyBaaGFuZyAoU2hhbmcgSGFpIFdlaSBDaHVhbmcgUnVhbiBKaWFuKSIsIm9pZCI6IjQ3NjgwMTFhLTY2NjgtNGFlNC1hYmYwLTU3NDM2ZGIyODQ1MSIsIm9ucHJlbV9zaWQiOiJTLTEtNS0yMS0yMTQ2NzczMDg1LTkwMzM2MzI4NS03MTkzNDQ3MDctMTg4MDU0NSIsInB1aWQiOiIxMDAzMDAwMDhDMjJBQkRFIiwic2NwIjoiQ29udGVudC5DcmVhdGUgRGFzaGJvYXJkLlJlYWQuQWxsIERhdGEuQWx0ZXJfQW55IERhdGFzZXQuUmVhZC5BbGwgRGF0YXNldC5SZWFkV3JpdGUuQWxsIEdyb3VwLlJlYWQgR3JvdXAuUmVhZC5BbGwgTWV0YWRhdGEuVmlld19BbnkgUmVwb3J0LlJlYWQuQWxsIFJlcG9ydC5SZWFkV3JpdGUuQWxsIiwic3ViIjoiNDQ2MVF0VDh6MGpTdHMxV29lZmVHRk5RMkhMQ1VKcWF6SDVuOEJLWnRVUSIsInRpZCI6IjcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0NyIsInVuaXF1ZV9uYW1lIjoidi1sdnpoYW5AbWljcm9zb2Z0LmNvbSIsInVwbiI6InYtbHZ6aGFuQG1pY3Jvc29mdC5jb20iLCJ2ZXIiOiIxLjAifQ.L5hpKJgcNR4s24ev51El8zWXpb3GGN0_ElyW7XQwpzOHs_CmwoB9M9nddRaih1ZY61dEWjxP8ZCDdWSnzGfxAyOGovgQ3ktEMa5QRiwdgxA3EczeqiaP5DoHRhXSADH8XioeJUWM1dNpiBJ42-Dc_1s4YmQHB4J1dIupMx_iVxThcOPRM-nnE8ikCpDRGzP2uIOMr-MKfPUwcScDDO8fhKItptvhh2R6xFmfvquKRNjU_g0xKtgCIn1bYzwcREA7vYjFeWlt90OLfa9FquoKiU7CggmmJTCotTMlIHKHxkJh2ofxQxX5PSPI6BwMx6UxozornpJbLvZOYhmm6C6RWg")
$headers.Add("Content-Type","application/json")


$uri = "https://api.powerbi.com/v1.0/myorg/groups/$groupsPath/datasets/$datasetID/refreshes"

try{
Invoke-WebRequest -Uri $uri -Headers $headers -Method POST
}

catch [Net.WebException] {

$ex=$_

if  ($ex-ne$null) {
$resp=$ex.Exception.Response;
$rs=$resp.GetResponseStream();
[System.IO.StreamReader]$sr=New-Object System.IO.StreamReader($rs);
[string]$results=$sr.ReadToEnd();

Write-Host $results

            }

}

 

 

View solution in original post

5 REPLIES 5
Microsoft Eric_Zhang
Microsoft

Re: Problem when calling Dataset refresh API


@nphdiem95 wrote:

Hi all,

 

I recently created a Function App to call dataset refresh API. The first call succeeded, but every calls after that raised 400 Bad Request.

h1.png

 

What is the reason of this error, and how can I fix it?

 

Thanks,

 

Diem


@nphdiem95

Instead of the simple 400 error, try to output the details error message with try catch block.

 

$groupsPath ="dc581184-a209-463b-8446-5432f16b6c15" 
$datasetID = "1f6285a5-7b98-4758-8f81-77b7ae5637d6"

$headers = @{}
$headers.Add("Authorization","Bearer eyJxxxxxxxxxxxxxxQvNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3LyIsImlhdCI6MTUwNTI3MDA5NSwibmJmIjoxNTA1MjcwMDk1LCJleHAiOjE1MDUyNzM5OTUsImFjciI6IjEiLCJhaW8iOiJZMlZnWUxEOFhTdkt6bXEyc09HSDFINmR4U1p6VXJRVFRrMTIyMjcrYVZWZnZQTVI5dHNBIiwiYW1yIjpbInB3ZCJdLCJhcHBpZCI6IjQ5ZGYxYmM3LWRiNjgtNGZiNC05MWMwLTZkOTNmNzcwZDFhNCIsImFwcGlkYWNyIjoiMCIsImZhbWlseV9uYW1lIjoiWmhhbmciLCJnaXZlbl9uYW1lIjoiRXJpYyIsImlwYWRkciI6IjE2Ny4yMjAuMjU1LjgiLCJuYW1lIjoiRXJpYyBaaGFuZyAoU2hhbmcgSGFpIFdlaSBDaHVhbmcgUnVhbiBKaWFuKSIsIm9pZCI6IjQ3NjgwMTFhLTY2NjgtNGFlNC1hYmYwLTU3NDM2ZGIyODQ1MSIsIm9ucHJlbV9zaWQiOiJTLTEtNS0yMS0yMTQ2NzczMDg1LTkwMzM2MzI4NS03MTkzNDQ3MDctMTg4MDU0NSIsInB1aWQiOiIxMDAzMDAwMDhDMjJBQkRFIiwic2NwIjoiQ29udGVudC5DcmVhdGUgRGFzaGJvYXJkLlJlYWQuQWxsIERhdGEuQWx0ZXJfQW55IERhdGFzZXQuUmVhZC5BbGwgRGF0YXNldC5SZWFkV3JpdGUuQWxsIEdyb3VwLlJlYWQgR3JvdXAuUmVhZC5BbGwgTWV0YWRhdGEuVmlld19BbnkgUmVwb3J0LlJlYWQuQWxsIFJlcG9ydC5SZWFkV3JpdGUuQWxsIiwic3ViIjoiNDQ2MVF0VDh6MGpTdHMxV29lZmVHRk5RMkhMQ1VKcWF6SDVuOEJLWnRVUSIsInRpZCI6IjcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0NyIsInVuaXF1ZV9uYW1lIjoidi1sdnpoYW5AbWljcm9zb2Z0LmNvbSIsInVwbiI6InYtbHZ6aGFuQG1pY3Jvc29mdC5jb20iLCJ2ZXIiOiIxLjAifQ.L5hpKJgcNR4s24ev51El8zWXpb3GGN0_ElyW7XQwpzOHs_CmwoB9M9nddRaih1ZY61dEWjxP8ZCDdWSnzGfxAyOGovgQ3ktEMa5QRiwdgxA3EczeqiaP5DoHRhXSADH8XioeJUWM1dNpiBJ42-Dc_1s4YmQHB4J1dIupMx_iVxThcOPRM-nnE8ikCpDRGzP2uIOMr-MKfPUwcScDDO8fhKItptvhh2R6xFmfvquKRNjU_g0xKtgCIn1bYzwcREA7vYjFeWlt90OLfa9FquoKiU7CggmmJTCotTMlIHKHxkJh2ofxQxX5PSPI6BwMx6UxozornpJbLvZOYhmm6C6RWg")
$headers.Add("Content-Type","application/json")


$uri = "https://api.powerbi.com/v1.0/myorg/groups/$groupsPath/datasets/$datasetID/refreshes"

try{
Invoke-WebRequest -Uri $uri -Headers $headers -Method POST
}

catch [Net.WebException] {

$ex=$_

if  ($ex-ne$null) {
$resp=$ex.Exception.Response;
$rs=$resp.GetResponseStream();
[System.IO.StreamReader]$sr=New-Object System.IO.StreamReader($rs);
[string]$results=$sr.ReadToEnd();

Write-Host $results

            }

}

 

 

View solution in original post

Highlighted
Juramirez Resolver I
Resolver I

Re: Problem when calling Dataset refresh API

Hi @nphdiem95


Where did you find examples to do this? Can you provide me the example code?


Thanks in advance

nphdiem95
Frequent Visitor

Re: Problem when calling Dataset refresh API

alexisc67 Helper I
Helper I

Re: Problem when calling Dataset refresh API

Hi,

 

I am having the same problem now. I am using c#, now after the first success I get a 400 error every time. How did you solve your problem?

 

Thanks in advance.

 

Alexis

realquo
Regular Visitor

Re: Problem when calling Dataset refresh API

I was in the same situation and this helped me to understand that the error was due to an excessive number of request (more than 😎 in the 24 hours, thanks.

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors