Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.
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:
New-PowerBIReport -Path $pbixFilePath `
-Name $reportName `
-WorkspaceId $workspaceId `
-ConflictAction CreateOrOverwrite
3. 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=CreateOrOv...
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.
No problem @andrii_k .
Thanks for the extra detail!
Yes, I understand that you are ultimately wanting to publish a report with live connection to semantic model to the target workspace.
I'm trying to isolate the cause of the error, which I suspect may relate to the semantic model that the report is live-connected to.
If the downloaded report has a live connection to an existing semantc model in Workspace A, and is then published to Workspace B (using any means), the report will remain live-connected to the semantic model in Workspace A, and will not automatically "rebind" to any semantic model in Workspsace B.
To bind the report to the semantic model in Workspace B, you would need to either need to change the live connection before publishing, or publish first then rebind using Reports - Rebind Report In Group (unfortunately not available via cmdlets as far as I'm aware).
If the account that is publishing the report with New-PowerBIReport does not have suitable permissions to access the semantic model in Workspace A, then New-PowerBIReport will return an error. Uploading/publishing the report manually with the same account would also return an error.
I suggest attempting to manually to upload the report to the target workspace using "Import" within the Workspace, with the same account that is being used for New-PowerBIReport. If you receive an error message, then that would confirm that's the issue.
Hi @OwenAuger ,
Thank you for the suggestion. We used two separate accounts per each Power BI workspace and each account had permissions only for its workspace. After creating a separate account that has permissions to both workspaces, it resolved the issue and we can successfully publish reports now.
We also updated our scripts to publish a report first and then rebind it to use a dataset in a target workspace using Reports - Rebind Report In Group. However, after rebinding, it just creates a separate copy of the same report each time we publish a report with the same name even though we use the "ConflictAction CreateOrOverwrite" paramter for the "New-PowerBIReport" cmdlt in our scripts. We need to overwrite the report instead. Is there a way to handle it or maybe there is a way to change the live connection before publishing by using scripts?
Hi @andrii_k , Thank you for reaching out to the Microsoft Community Forum.
The New-PowerBIReport cmdlet is not the right tool. While it includes a ConflictAction CreateOrOverwrite parameter, it fails when the report is connected to an external dataset. This is because Power BI treats the report as a new object due to the embedded dataset reference, which it doesn't resolve correctly during publish. Instead, you should use the Import-PowerBIReport cmdlet, which reliably supports overwriting reports in a workspace. This method ensures the report is replaced without needing to delete the existing one manually. However, since the .pbix file retains its original dataset binding from the source workspace, it will continue to point to that dataset even after import.
To fix this, you must explicitly rebind the report to the dataset in the target workspace using the REST API. Power BI does not automatically switch the connection, even if the target dataset has the same name or schema. Rebinding ensures the report uses the correct semantic model in the destination workspace and avoids any cross-workspace dependency issues. Make sure you authenticate using Connect-PowerBIServiceAccount or a service principal and obtain a valid $accessToken for the REST API call. After this process, your report will be updated, overwrite the existing version and point to the correct semantic model in the same workspace.
If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
Hello @v-hashadapu , thanks for your reply.
I'm getting the following error when trying to use 'Import-PowerBIReport' cmdlt:
The term 'Import-PowerBIReport' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
And I don't find it in the official docummentation: https://learn.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.reports/?view=powerbi-ps
Can you please advise?
Hi @andrii_k
Just checking to rule it out: Does the semantic model that the downloaded report is connected to still exist when executing New-PowerBIReport?
I tried to reproduce your error, and the only way I could produce an error (though a slightly different message) with New-PowerBIReport was to download the report PBIX, delete the semantic model that the report was connected to (after downloading) then execute New-PowerBIReport.
Would you consider using Copy-PowerBIReport which avoids downloading the PBIX and allows you to specify a target semantic model?
This script may also be a useful reference:
https://github.com/Microsoft/powerbi-powershell/blob/master/examples/CopyWorkspaceSampleScript.ps1
Hi @OwenAuger ,
Thanks for replying to this thread.
Yes, the semantic model that the downloaded report is connected to still exists when executing New-PowerBIReport.
Our scenario is as follows:
or create a new PBIX report using Power BI Desktop. In both cases, PBIX reports have relationships with a Semantic Model, so the reports don't contain a Semantic Model but use a live connection to data online.
However, we are getting "Response : Bad Request (400): {"error":{"code":"PowerBIModelNotFoundException","pbi.error":{"code":"PowerBIModelNotFoundException","parameters":{},"details":[],"exceptionCulprit":1}}}" error message while publishing the updated PBIX report that doesn't contain a Semantic Model but use a live connection to data online. It works fine if we publish a PBIX report that contains a Semantic Model, but we don't want to keep semantic models for each PBIX report. Our use case is to successfully publish a PBIX report without a semantic model using MicrosoftPowerBIMgmt.Reports module so that the PBIX report should be able to find and establish relationships with a semantic model that is already in a target Power BI workspace.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
37 | |
26 | |
22 | |
10 | |
10 |