microsoft / ReportingServicesTools

Reporting Services Powershell Tools
MIT License
458 stars 213 forks source link

Failed to create catalog item: The remote server returned an error: (422) #404

Open lorenzouriel opened 1 year ago

lorenzouriel commented 1 year ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? Error when I try to upload a pbix file

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. He creates the session and publish the folder:

# establish session w/ Report Server
$session = New-RsRestSession -ReportPortalUri $serverUrl

# create folder (optional)
New-RsRestFolder -WebSession $session -RsFolder $dashboardFolder -FolderName $dashboardFolder -Verbose

But, when I publish the .pbix file to report server

# upload copy of PBIX to new folder
Write-RsRestCatalogItem -WebSession $session -Path $dashboardtLocalPath -RsFolder /$dashboardFolder -Verbose

Returns a error:

Write-RsRestCatalogItem : System.Exception: Failed to create catalog item: The remote server returned an error: (422) Unprocessable Entity. ---> System.Net.WebException: The remote server 
returned an error: (422) Unprocessable Entity.
   at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
   at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
   --- End of inner exception stack trace ---
At C:\SILO\deploy_pbix_reports.ps1:15 char:1
+ Write-RsRestCatalogItem -WebSession $session -Path $dashboardtLocalPa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-RsRestCatalogItem

What is the expected behavior? Publish with success

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts? No, but i see a bug with the same error open in 2020 - https://github.com/microsoft/ReportingServicesTools/issues/304

greenmtnsun commented 11 months ago

I am having this EXACT problem with a fresh install of PBIRS.

I'm using this for Powershell: PSVersion 5.1.14393.6343
I'm using 0.0.8.0 for ReportingServicesTools
For the OS I'm on Windows Server 2016.
For Power BI I'm on January 2023 for both Power BI Desktop and the PBIRS service. On prem, no gateway.

I checked and my experience is as described above. I could really use a fix!!!