Skip to content

PowerBIModelNotFoundException when publishing Power BI report to Azure Power BI #420

@cszendesk

Description

@cszendesk

We are using "MicrosoftPowerBIMgmt" module in our PowerShell scripts, specifically "New-PowerBIReport" cmdlt, to publish Power BI reports (.pbix) to Azure Power BI but getting this error message:

Bad Request (400): {"error":{"code":"PowerBIModelNotFoundException","pbi.error":{"code":"PowerBIModelNotFoundException","parameters":{},"details":[],"exceptionCulprit":1}}}

Steps to reproduce:

  1. Download a Power BI report (.pbix) from one Azure Power BI workspace with the option to download "A copy of your report with a live connection to data online (.pbix)"
  2. Use the following command to publish the report to another Azure Power BI workspace:
New-PowerBIReport -Path $pbixFilePath `
                  -Name $reportName `
                  -WorkspaceId $workspaceId `
                  -ConflictAction CreateOrOverwrite `
                  -ErrorAction SilentlyContinue
  1. Get this error message:
Response         : Bad Request (400): {"error":{"code":"PowerBIModelNotFoundException","pbi.error":{"code":"PowerBIModelNotFoundException","parameters":{},"details":[],"exceptionCulprit":1}}}
PowerBIErrorInfo : PowerBIModelNotFoundException
RequestId        : 1e56***-****-****-****-*********
ResponseDate     : Fri, 09 May 2025 14:45:18 GMT
RequestMethod    : POST
RequestUri       : https://api.powerbi.com/v1.0/myorg/groups/***/imports?datasetDisplayName=REO&nameConflict=CreateOrOverwrite
Exception        : Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'BadRequest'
                      at Microsoft.PowerBI.Api.V2.Imports.<UploadFile>d__8.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                      at Microsoft.PowerBI.Api.V2.Imports.<PostImportFileWithHttpMessage>d__7.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                      at Microsoft.PowerBI.Api.V2.ImportsExtensions.PostImportWithFileInGroup(IImports operations, 
                   String groupId, Stream fileStream, String datasetDisplayName, String nameConflict, Nullable`1 
                   skipReport)
                      at Microsoft.PowerBI.Common.Api.Reports.ReportsClient.PostImportForWorkspace(Guid workspaceId, 
                   String datasetDisplayName, String filePath, ImportConflictHandlerModeEnum nameConflict)
                      at Microsoft.PowerBI.Common.Api.Reports.ReportsClient.PostReportForWorkspace(Guid workspaceId, 
                   String reportName, String filePath, ImportConflictHandlerModeEnum nameConflict, Int32 timeout)
                      at Microsoft.PowerBI.Commands.Reports.NewPowerBIReport.ExecuteCmdlet()
                      at Microsoft.PowerBI.Commands.Common.PowerBICmdlet.ProcessRecord()
InnerException   : False

We have a semantic model (dataset) already uploaded to the Azure Power BI workspace with correct relationships, so we expect to upload successfully our report with a live connection to data online (.pbix) without containing a semantic model (dataset) in the report file. This works properly when we publish the report using Power BI Desktop, but it doesn't work using "MicrosoftPowerBIMgmt" module.

Please provide any suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions