cancel
Showing results for 
Search instead for 
Did you mean: 

dataflow refresh using api failed - 400 bad request

Hi there,

 

I am trying to refresh dataflows using the rest api: https://docs.microsoft.com/en-us/rest/api/power-bi/dataflows/refreshdataflow

 

And I am getting the following error:

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:2 char:1
+ Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST –Verbos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

The code:

function GetAuthToken
{
if(-not (Get-Module AzureRm.Profile)) {
Import-Module AzureRm.Profile
}

$redirectUri = "urn:ietf:wgSmiley Surprisedauth:2.0Smiley Surprisedob"



$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")

return $authResult
}

$token = GetAuthToken

$authHeader = @{
'Content-Type'='application/json'
'Authorization'=$token.CreateAuthorizationHeader()
}
$groupsPath = ""
if ($groupID -eq "me") {
$groupsPath = "myorg"
} else {
$groupsPath = "myorg/groups/$groupID"
}

Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST –Verbose
Status: New
Comments
Visitor

I am not sure is this a bug or not though, I can get dataflow list using same authenticaiton.

 

Anyone have ideas on this issue?

Moderator

Hi @SimonL7 ,

 

You need to pass "refreshRequest": "y" in your request body. For more information, please refer to this thread: https://community.powerbi.com/t5/Developer/Power-BI-API-Dataflow-Refresh-Operation/td-p/588556

 

Best Regards,
Qiuyun Yu