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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
gauravkh
Frequent Visitor

Issue in importing Dataflow using Powershell

Problem:
I need to import Dataflow json using Powershell
I created a copy of my Dataflow json file with a separate name and able to import using Powershell
It is able to Create the copied Dataflow
But when I run the function on original Dataflow json file it returns with exception: "The remote server returned an error: (404) Not Found."
I'm using the following function:

 

 

 

 

function ImportDataflow([string]$GroupID, [string]$DataflowName, [string]$DataflowDefinition) {

    $UserAccessToken = Get-PowerBIAccessToken
    $bearer = $UserAccessToken.Authorization.ToString()
    
    $DataflowListurl = "groups/$GroupID/dataflows"
    $flowItems = Invoke-PowerBIRestMethod -Method GET -Url $DataflowListurl | ConvertFrom-Json
    $flow = $flowItems.value | Where-Object { $_.name -eq $DataflowName }
    
    if ($flow) {
        $CreateOrReplace = "&nameConflict=CreateOrOverwrite"
        Write-Host "Overwriting Dataflow: $DataflowName";
    } else {
        $CreateOrReplace = ""
        Write-Host "Creating new Dataflow: $DataflowName";
    }
    

    $url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupID/imports?datasetDisplayName=model.json$CreateOrReplace"

    $boundary = [System.Guid]::NewGuid().ToString("N")
    $LF = [System.Environment]::NewLine
		
    $body = (
        "--$boundary",
        "Content-Disposition: form-data, name=`"model.json`" filename=`"model.json`"",
        "Content-Type: application/json$LF",
        $DataflowDefinition,
        "--$boundary--$LF"
    ) -join $LF

    $headers = @{
        'Authorization' = "$bearer"
        'Content-Type'  = "multipart/form-data; boundary=--$boundary"
    }
    
    Invoke-RestMethod -Uri $url -ContentType 'multipart/form-data' -Method POST -Headers $headers -Body $body
}

 

 

 

 

FYI - I am clearing Partition entity from $DataflowDefinition before passing it to the function

1 REPLY 1
gauravkh
Frequent Visitor

Found the workaround for this as we can't update Dataflows as of now

1. Delete the Dataflow, 

2. Delete the files from blob (if you have specific blob storage)

3. Recreate the Dataflow

4. Run the dataflow with full refresh

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.