Hi
I am working on publishing .rdl & .pbix report files to SSRS report server 2019 using the code below. Publish of .rdl files works fine but .pbix reports error.
Code:
private void PublishReports()
{
ReportService2010.ReportingService2010 rs = new ReportService2010.ReportingService2010();
rs.Url = "https://MyReportServer/ReportServer/reportservice2010.asmx";
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string strItemType = "Report";
string strName = "Test.pbix";
Byte[] definition = null;
ReportService2010.Warning[] warnings = null;
try
{
string strServerPath = @"C:\Temp\Test.pbix";
FileStream stream = File.OpenRead(strServerPath);
definition = new Byte[stream.Length];
stream.Read(definition, 0, (int)stream.Length);
stream.Close();
}
catch (IOException e)
{
MessageBox.Show(e.Message);
}
try
{
string parent = "/";
ReportService2010.CatalogItem report = rs.CreateCatalogItem(strItemType, strName, parent,true, definition, null, out warnings);
if (warnings != null)
{
foreach (ReportService2010.Warning warning in warnings)
{
MessageBox.Show(warning.Message);
}
}
else
MessageBox.Show("Report: {0} created successfully " + " with no warnings", strName);
}
catch (SoapException e)
{
MessageBox.Show(e.Detail.InnerXml.ToString());
}
}
Error:
The operation you are attempting on item '/Reports/Test' is not allowed for this item type. ---> Microsoft.ReportingServices.Diagnostics.Utilities.WrongItemTypeException: The operation you are attempting on item '/Reports/Test' is not allowed for this item type.
Can I use ReportingServices2010.asmx to publish both .rdl & .pbix reports? Please guide me.
Thank you