SimonL7's avatar
SimonL7
Regular Visitor
7 years ago
Status:
New

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:wg:oauth:2.0:oob"



$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

9 Comments

  • SimonL7's avatar
    SimonL7
    Regular 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?

  • mikesmith_bp's avatar
    mikesmith_bp
    Frequent Visitor

    I am getting the same error.  I am refreshing a dataflow via Power Automate.  It works fine for several refreshes.  Then it just seems to randomly "break" with error

    The backend request failed with error code '400'

     

    I also tried this on my co-workers cloud and had the same results. 

    My dataflow does have a web call in it.  But why would it work and then break?

  • Anonymous's avatar
    Anonymous
    Not applicable

    I get the same error since 07-Sep
    I exported the DS to a new WS
    After successful execution, it randomly breaks throwing The backend request failed with error code '400'

    Please, it is important to solve the problem because it depends on the intervention to end the flows

  • Anonymous's avatar
    Anonymous
    Not applicable

    I m having the same error when I try to trigger a Dataflow refresh via PowerAutomate

    Action 'Refresh_a_dataflow' failed
    The backend request failed with error code '400'

    Its very random and there is no addiotnal information to debug. Anyone you can help here?

    All the below failed status are due to the same reason :

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous I am facing the same problem and i cant solve it, did you find the solution???

  • mikesmith_bp's avatar
    mikesmith_bp
    Frequent Visitor

    I have not found a solution.  In my experience, the Power Platform is not 100% reliable.  I see 'weird' errors like this all of the time.

  • Anonymous I'm getting the same error when refreshing using power automate. It works at starting but then starts failing. Do anyone have an answer to this problem or is there any other approach we can follow