Monday, March 26, 2012

Invalid Path message

In the following code, I received an error on

execInfo = rsReportExec.LoadReport(strReportPath, strHistoryID). The errro was "System.Web.Services.Protocols.SoapException: The path of the item "http://localhost/ReportServer/Pages/ReportViewer.aspx?/CAITReports/rptIssuesByRole&rs:Command=Render&intProjectID=119&nvchrWhoRan=DYW" is not valid. The path must be less than 260 characters long and must start with slash. Other restrictions apply. > Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException: The path of the item "http://localhost/ReportServer/Pages/ReportViewer.aspx?/CAITReports/rptIssuesByRole&rs:Command=Render&intProjectID=119&nvchrWhoRan=DYW" is not valid. The path must be less than 260 characters long and must start with slash. Other restrictions apply.

I copied and pasted the path on the URL and it worked. What did I miss in the code? Why strHistoryID is required as it is nothing? Please refer to http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsexecutionservice2005.reportexecutionservice.render.aspx

Private Sub sExecuteReportingServicesReport()

Dim rsReportExec As ReportExecutionService = New ReportExecutionService

rsReportExec.Credentials = System.Net.CredentialCache.DefaultCredentials

'rsReportExec.Url = "http://localhost/reportserver/ReportExecution2005.asmx"

Dim byteResult() As Byte = Nothing

Dim strReportPath As String = "http://localhost/ReportServer/Pages/ReportViewer.aspx?/CAITReports/rptIssuesByRole&rs:Command=Render&intProjectID=" & Me.cboProject.SelectedValue & "&nvchrWhoRan=" & Session("strEmployeeName")

'Dim strReportPath As String = "/Pages/ReportViewer.aspx?/CAIT/rptIssuesByRole&rs:Command=Render&intProjectID=" & Me.cboProject.SelectedValue & "&nvchrWhoRan=" & Session("strEmployeeName")

Dim strFormat As String = "MSWord"

Dim strHistoryID As String = Nothing

Dim strEncoding As String = ""

Dim strMineType As String = ""

Dim strExtension As String = ""

Dim wrnWarnings() As Warning = Nothing

Dim strStreamIDs() As String = Nothing

Dim execInfo As New ExecutionInfo

Dim execHeader As New ExecutionHeader

rsReportExec.ExecutionHeaderValue = execHeader

execInfo = rsReportExec.LoadReport(strReportPath, strHistoryID)

Dim strSessionID As String = rsReportExec.ExecutionHeaderValue.ExecutionID

byteResult = rsReportExec.Render(strFormat, Nothing, strExtension, strEncoding, strMineType, wrnWarnings, strStreamIDs)

Response.ClearContent()

Response.AppendHeader("content-length", byteResult.Length.ToString)

Response.ContentType = "application/MSWord"

Response.BinaryWrite(byteResult)

Response.Flush()

Response.Close()

End Sub

Thanks.

DanYeung

The report path should be like /ReportFolder/ReportName

What you have given is URL. Check it for yourself in the msdn link you have given. There is nothing to do with hitory id.

Shyam

No comments:

Post a Comment