Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Eric_Zhang
Employee
Employee


@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
realquo
Regular Visitor

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.

alexisc67
Helper I
Helper I

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

Eric_Zhang
Employee
Employee


@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

            }

}

 

 

Hi @nphdiem95


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


Thanks in advance

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Kudoed Authors