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
GarethNW
New Member

Problem publishing Report that uses a separate On prem dataset via PowerShell

My goal is to set up an Azure DevOps pipeline that can publish a report to the Development workspace.

 

The below code uses a service principle account to authenticate and then successfully publishes my test .pbix file (LocalReportModel.pbix") this file is a simple report and model structure

 

Import-Module MicrosoftPowerBIMgmt

$clientId = "****"
$clientSecret = "****"
$tenantId = "****"

$secpasswd = ConvertTo-SecureString $clientSecret -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($clientId, $secpasswd)

Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId
$workspaceName = "Development"
$workspace = Get-PowerBIWorkspace -Name $workspaceName
$file = "C:\Tasks\BI\LocalReportModel.pbix"

New-PowerBIReport -Path $file -Workspace $workspace -ConflictAction CreateOrOverwrite

 

 
We use On Premises Gateways so our model/dataset it not stored within the .pbix file
When I try the above with the file ReportOnly.pbix I get the error

 

New-PowerBIReport: Operation returned an invalid status code 'BadRequest'

How can I add the link to the dataset currently within the workspace so that it will publish?

Thank you for any help you can offer.

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @GarethNW ,

The error message "New-PowerBIReport: Operation returned an invalid status code 'BadRequest'" usually occurs when there is an issue with the request being sent to the Power BI service. One possible cause could be that the service principal being used does not have the necessary permissions to publish the report. You can check the permissions for the app in the Azure Portal by running the command "Get-Help Connect-DataGatewayServiceAccount -Examples". For Service Principal Scenario, use the "Get-Help Connect-DataGatewayServiceAccount -Examples" to get information about the permissions on the azure portal. In the Azure portal these will show as the Permission names "Tenant.Read.All" and "Tenant.ReadWrite.All" with the "Application" type under the Power BI Service API.

Another possible cause could be that the report name already exists in the Power BI service and is connected to the same dataset. In this case, you can try publishing the report with a different name.

Best Regards

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

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.

Top Kudoed Authors