使用PowerShell上传RDL至SSRS时遇架构验证错误求助
SSRS 2019 PowerShell上传RDL失败但UI正常的问题
环境与上传脚本
使用SQL Server 2019 Reporting Services(版本15.0.8863.19101),通过以下PowerShell脚本上传RDL文件至指定文件夹:
$sourceItemPath = 'C:\Temp\ReportFolder\Report.rdl' $reportName = 'Report' $apiPath = 'http://localhost/reports/api/v2.0' $creds = New-Object System.Management.Automation.PSCredential ($SSRSReportUser, $SecurePassword) $targetPath = "/Reports" $sourceFileContent = [System.IO.File]::ReadAllBytes($sourceItemPath) $sourceFileContent2 = [System.Convert]::ToBase64String( $sourceFileContent ) # ------------------ # Create Report # ------------------ $CreateReportJSON= ' { "@odata.type": "#Model.Report", "Content": "YYY", "ContentType": "application/rdl", "Name": "XXX", "Path": "/ZZZ/XXX" } ' $targetPath = $targetPath.Replace('/','') $CreateReportJSON = $CreateReportJSON.Replace('XXX',$reportName) $CreateReportJSON = $CreateReportJSON.Replace('YYY',$sourceFileContent2) $CreateReportJSON = $CreateReportJSON.Replace('ZZZ',$targetPath) $CreateReportURI = "$apiPath/Reports(Path='/$targetPath')" $createReportResponse = Invoke-RestMethod -Uri $CreateReportURI -Method POST -ContentType 'application/json' -Body $CreateReportJSON -Credential $creds
执行错误
运行脚本时返回以下错误:
Invoke-RestMethod : { "error":{ "code":"1027","message":"The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: Invalid character in the given encoding. Line 1206, position 80." } }
RDL文件头部信息
该RDL文件开头内容:
<?xml version="1.0" encoding="utf-8"?> <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:am="http://schemas.microsoft.com/sqlserver/reporting/authoringmetadata">
关键现象
通过SSRS UI可以正常上传该文件!
RSPortal日志(2024-07-10 15:34 EDT)
2024-07-10 15:14:40.4731|INFO|26|Received request POST /api/v2.0/Reports| RequestID = s_f7b1ad7e-cae6-42dc-a0c4-e89f532b2e5c 2024-07-10 15:14:40.6673|ERROR|26|OData exception occurred: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: Invalid character in the given encoding. Line 1206, position 80. at Microsoft.ReportingServices.Library.ReportingService2010Impl.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, ItemType ItemType, CatalogItem& ItemInfo, Warning[]& Warnings) at Microsoft.ReportingServices.Library.ReportingService2010Impl.CreateCatalogItem(String ItemType, String Name, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, CatalogItem& ItemInfo, Warning[]& Warnings) at Microsoft.ReportingServices.WebServer.ReportingService2010.CreateCatalogItem(String ItemType, String Name, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, CatalogItem& ItemInfo, Warning[]& Warnings) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at Microsoft.SqlServer.ReportingServices2010.ReportingService2010.CreateCatalogItem(String ItemType, String Name, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings) at Microsoft.SqlServer.ReportingServices2010.RSConnection2010.<>c__DisplayClass120_0.<CreateCatalogItem>b__0() at Microsoft.SqlServer.ReportingServices2010.RSConnection2010.SoapMethodWrapper`1.ExecuteMethod(Boolean setConnectionProtocol) at Microsoft.SqlServer.ReportingServices2010.RSConnection2010.CreateCatalogItem(String itemType, String name, String parent, Boolean overwrite, Byte[] definition, Property[] properties, Warning[]& warnings) at Microsoft.ReportingServices.Portal.Services.SoapProxy.SoapRS2010Proxy.<>c__DisplayClass3_0.<CreateCatalogItem>b__0() at Microsoft.ReportingServices.Portal.Services.SoapProxy.SoapAuthenticationHelper.ExecuteWithWindowsAuth[TReturn](SoapHttpClientProtocol soapClient, IPrincipal userPrincipal, Func`1 func) at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.CreateReport(RSService rsService, IPrincipal userPrincipal, String reportName, String parentFolder, Boolean overwrite, Byte[] definition, Property[] properties) at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.CreateItem(IPrincipal userPrincipal, CatalogItem catalogItem, CatalogItem& createdItem) at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.Create[T](IPrincipal userPrincipal, T catalogItem, T& createdItem) at Microsoft.ReportingServices.Portal.ODataWebApi.Controllers.Reflection.EntitySetReflectionODataController`1.Post(ODataPath oDataPath, T value) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- 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 System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.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 System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.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 System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext().| RequestID = s_f7b1ad7e-cae6-42dc-a0c4-e89f532b2e5c 2024-07-10 15:14:40.6673|INFO|26|Sending response. Response code 500, Elapsed time 0:00:00.1955089| RequestID = s_f7b1ad7e-cae6-42dc-a0c4-e89f532b2e5c
疑问
- 为何PowerShell上传失败但UI可以正常上传?
- 是否可以关闭SSRS的架构验证?
内容的提问来源于stack exchange,提问作者WKNav4997
相关产品推荐
相关产品推荐

