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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Import Dataflow in Power BI Service

I use this script to import a dataflow : 

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "...", ("..." | ConvertTo-SecureString -AsPlainText -Force)

Connect-PowerBIServiceAccount -ServicePrincipal -Tenant "..." -Credential $credential -Environment "Public"

$workspaceName = "WKS - DTS [DEV]"

$DataflowImportFileName = "C:\Users\cbonier\Documents\DTF FINANCE.json"

$DataflowDefinition = [IO.File]::ReadAllText($DataflowImportFileName)


$UserAccessToken = Get-PowerBIAccessToken
$bearer = $UserAccessToken.Authorization.ToString()


$workspace = Get-PowerBIWorkspace -Name $workspaceName
$workspaceId = $workspace.Id

$importsUrl = "https://api.powerbi.com/v1.0/myorg/groups/$workspaceId/imports?datasetDisplayName=DTF FINANCE.json"

$boundary = [System.Guid]::NewGuid().ToString("N")
$LF = [System.Environment]::NewLine

$contentType = "multipart/from-data; boundary=""$boundary"""

$body = (
"--$boundary",
"Content-Disposition: form-data $LF",
$DataflowDefinition,
"--$boundary--$LF"
) -join $LF

$header = @{
    'Authorization' = "$bearer"
    'Content-Type' = "$contentType"
}

Invoke-RestMethod -Uri $importsUrl -ContentType $contentType -Method Post -Headers $header -Body $body

 But I have this error : 

Charline74_0-1663076184097.png

 

2 REPLIES 2
Anonymous
Not applicable

Hi @v-chenwuz-msft

 

What do you mean when you write : "This parameter should be hardcoded to model.json." ? 

 

I tried this script but it doesn't work :

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/cfafbeb1-8037-4d0c-896e-a46fb27ff229/imports?datasetDisplayName=model.json&nameConflict=Abort&skipReport=True" -Method Post

 

Error message : 

AVERTISSEMENT : The Body parameter was null, the request may be invalid when Method par
ameter is Post.
Invoke-PowerBIRestMethod : Une ou plusieurs erreurs se sont produites.
Au caractère Ligne:5 : 1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
    + FullyQualifiedErrorId : Une ou plusieurs erreurs se sont produites.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

POST https://api.powerbi.com/v1.0/myorg/groups/cfafbeb1-8037-4d0c-896e-a46fb27ff229/imports?datasetDisplayName=model.json&nameConflict=Abort&skipReport=True 

This parameter should be hardcoded to model.json.

 

For more details, you can refer this link.

Imports - Post Import In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.