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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Uploading Paginated reports files by Powershell cmdlet or API

Hello Guys

I tried uploading paginated reports by powershell but I haven't find the right command to do it, I've used the following lines to upload datasets and reports but it doesnt work for uploading paginated reports.

 

$datasetsFilenames = Get-ChildItem "C:\Users\jose\Repos\PBI Reports\PaginatedReports\"

$clientsecret="xxxxxxx" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList XXXXXXX, $clientSecret
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId XXXXXXX

foreach ($item in $datasetsFilenames) {
try {
#Call Powerbi APi for Create a Report
$Get = New-PowerBIReport -Path $item.FullName -WorkspaceId XXXXXXX
Write-Host $Get
}
catch [Exception] {
$ErrorMessage = $_.Exception.Message
Write-Host "The DataSets could not be uploaded. The error message was $ErrorMessage"`n -ForegroundColor Red
}
}

 

I've used the previous code to upload datasets and reports through the command " New-PowerBIReport -Path $item.FullName -WorkspaceId XXXXXXX" but I wasn't be able to do it for all my paginated reports.

 

Does anybody know it?

 

Regards.

1 REPLY 1
lbendlin
Super User
Super User

If anything else fails you can always use the Invoke-RestMethod calls 

 

$uri = “https://api.powerbi.com/v1.0/myorg/groups/{groupId}/imports?datasetDisplayName={datasetDisplayName}

# issue the upload request
$FileUpload = Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST -body $body

 

etc.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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