Accessing a Report Server Using a URL POST Request


You may have a need to access a report server, not through GET requests or standard browser access, but through POST requests. The times when you might need to use a POST request in your application are as follows: 



  • You need to build a custom user interface with your own toolbar, parameters area, report exporting features, etc. This is often the case when you want to support a control that enables multi-select parameters.
  • You have a parameter list that causes your URL access string to exceed your browser's character limit on GET requests (sometimes as little as 256 characters).
  • You have some other reason to use POST requests that I haven't considered.

The following is a very simple example of using a form post method in your Web application to access a report server. Simply copy the HTML source into two separate files as indicated below and deploy the files to a virtual directory on your report server. Then access the file default.htm.


toolbar.htm


Contains a toolbar that can be used to enter a parameter and view the Sales Order Detail report.


<HTML>
<BODY>
<FORM id="frmRender" action="http://localhost/reportserver?/SampleReports/Sales Order Detail"
method="post" target="Main">
   <INPUT type="hidden" name="rs:Command" value="Render">
   <INPUT type="hidden" name="rc:LinkTarget" value="main">
   <INPUT type="hidden" name="rs:Format" value="HTML4.0">
   <INPUT type="hidden" name="rc:Parameters" value="False">
   <INPUT type="text" name="SalesOrderNumber" value="SO5414">
   <INPUT type="submit" value="View Report">
</FORM>
</BODY>
</HTML>


default.htm


Provides two frames that can be used to host the toolbar and view the rendered report.


<HTML>
<BODY>
<IFRAME ID="Top" src="toolbar.htm" width=100% height=10% />
<IFRAME ID="Main" Name="Main" src="" width=100% height=90% />
</BODY>
</HTML>


Okay, I hope this simple example gives you some ideas to work with.

Comments (25)
  1. kyle says:

    how can you pass the windows user name in this post statement to view/render this report?

  2. Bryan Keller says:

    Hi Kyle,

    You cannot pass report server usernames and passwords via a URL, only data source usernames and passwords. The authentication method of the report server determines usernames and passwords (integrated, Basic over SSL, etc.) but you will still get prompted for username and password for the server. There is a sample coming out in a few weeks that will show you how to use Forms authentication with Reporting Services, but the limitation still remains that you cannot pass report server usernames and passwords using URL access.

  3. kyle says:

    Thanks, for the comments bryan! 🙂 That would be a great example. We are struggling with finding out a way to access the reports without the dialog popping up and still keeping things secure.

  4. Bret says:

    Bryan,

    Is there a way to tell Reporting Services to ignore extra parameters passed via the POST? I have some other controls on the page which are causing problems when I post to the report page. The error is :"An attempt was made to set a report parameter ‘URL’ that is not defined in this report. (rsUnknownReportParameter) Get Online Help"

    Thanks,

    Bret

  5. Bryan Keller says:

    Not really. You would have to prefix them with a custom identifier, so that the report server would not interpret them as report parameters.

  6. Bret says:

    Bryan,

    Thanks for your response. I fixed my previous problem, but not I am running into an issue with RS any time the length of the url and parameters combination are greater than 1495 characters. It brings up the report page and sits on the "Report is being generated" screen forever (I have yet to see it do anything past that). It happens when I pass the parameters with both the URL and POST. Any ideas?

    Thanks,

    Bret

  7. Chris says:

    Hi Bryan,

    Can you explain how we can do ‘single sign on’ with forms authentication (which we have working)? We currently have an ASP.NET application that uses Forms auth, within which we make calls to the RS webservice – which necessitates a call to the ‘LogonUser(username, password)’ method. What we want to try to avoid popping up the logon screen a second time, and we also want to avoid storing the user’s password in his session.

    Thanks,

    Chris

  8. Bryan Keller says:

    You don’t really have to call LogonUser. If you have already authenticated your users through some other system, you simply have to add our cookie and HTTP header to the request and response headers. I would recommend posting this question to our public newsgroup

    Microsoft.Public.SQLServer.ReportingSvcs

  9. Raj Chidipudi says:

    THanks for the tip Bryan.

    But don’t really know how to "add our cookie and HTTP header to the request and response headers".

    It would be really helpful if you can provide some sample code for accomplishing the above task.

    Regards

    Raj Chidipudi

  10. Tammy says:

    Hi Brian,

    Did you have a response to Bret’s post on 4/5? I am concerned with the same issue… having too long of a URL…

    Thanks!

  11. Shawn says:

    "you simply have to add our cookie and HTTP header to the request and response headers"

    What header and cookie?

  12. Thomas Hansen says:

    Hi

    I want to execute a report using an URL request and the output must be delivered as a PDF-file. That’s no problem – BUT then user has to name and save the PDF-file. I would be wery useful if the name and the directory of the output file could be set directly in the URL-Request.

    Thanks!

  13. Arron says:

    My application is a web application and use post request, if I put data source username/password on a form hidden variable then any one can see it by view source , how to avoid that and make it secure?

    Thanks!

  14. Eralper Yılmaz says:

    Hi Bryan,

    Great site on Reporting Services. Thanks…

    I want to use hidden parameters after the service patch. But could not find any sample about using hidden parameters.

  15. Bryan Keller says:

    Hi Eralper,

    Report Designer is not my specialty, but I believe that if you clear the prompt string on the parameters page, that will make the parameter hidden. There should be something on it in the SP1 readme.

  16. Alex says:

    Hi Brian

    How can I make report server working use Netscape? By default, it seems only work for IE.

  17. Lee says:

    If I use URL access, choice Excel as the fromat, I will be asked "Would you liek to open the file or save it to yoour computer?" twice.

    When I was asked 1st time, I click "Open", then I would be asked again. After the second time I had been asked, I clicked "Open" then it can be really opend? Anyone can point me out why? and how to avoid to be asked twice.

    Thanks!

    <HTML>

    <BODY>

    <FORM id="frmRender" action="http://localhost/reportserver?/SampleReports/Sales Order Detail"

    method="post" target="Main">

    <INPUT type="hidden" name="rs:Command" value="Render">

    <INPUT type="hidden" name="rc:LinkTarget" value="main">

    <INPUT type="hidden" name="rs:Format" value="EXCEL">

    <INPUT type="hidden" name="rc:Parameters" value="False">

    <INPUT type="text" name="SalesOrderNumber" value="SO5414">

    <INPUT type="submit" value="View Report">

    </FORM>

    </BODY>

    </HTML>

  18. Parvath Reddy says:

    I am trying to use URL Access to get a page on to a frame and I am trying to write a toolbar for my own. Now I am able to use Section=1 in the &rc to go to first page, but is there a way to find the number of pages. so that I can use that to navigate the pages.

    Thanks

  19. Bryan Keller says:

    There is no real way to determine Section count or page number ahead of time. This was simply an oversight and we are looking for ways to add this in future versions. As for using section, it should work just fine. Here is a sample URL based on the report samples and it worked for me as expected:

    http://servername/ReportServer?%2fSampleReports%2fProduct+Catalog&rs%3aCommand=Render&rc%3aSection=2&rc%3aDocMap=false&rc%3aToolbar=false

  20. Parvath Reddy says:

    I am trying to use URL Access to get a page on to a frame and I am trying to write a toolbar of my own that simulates and does some extra functionality. Now I can use Section=1 in the &rc to go to first page, but is there a way to find the number of pages or access the javascript the original toolbar uses.

    Thanks

  21. Rehan khan says:

    Hi Bryan

    This solution is not working for me

    I have SQL Reporting Enterprise version with SP1

    I followed all the steps which you told, but it did’nt work

    Thanks

  22. Rehan khan says:

    Hi Bryan

    It is now working now but problem still what i facing is still the parameter are passed as a query string to report which i don’t want.

    Even if i am sedning parameter value using POST method but still values are going as a query string

    Can you let me know what is the issue

    Rehan

  23. Rehan khan says:

    Hi Bryan

    It is now working now but problem still what i facing is still the parameter are passed as a query string to report which i don’t want.

    Even if i am sedning parameter value using POST method but still values are going as a query string

    Can you let me know what is the issue

    Rehan

  24. Susie says:

    Hi,

    I am also accessing reports using direct url access. Is there a way to avoid specifying the exact parameter name when passing values for the report parameter.

    ex fname=&lname=&mname=

    I am comparing it to crystal report where we just usually use prompt0=&prompt1=&prompt2= and the report will pass it to the parameters fname,lname,mname respectively.

    This way, if we change the name of the parameter in the stored procedure, lets say, firstname instead of fname and so on, we don’t have to change the page calling the report.

  25. [This will be a list of resources I point people to all the time….just putting ’em all in one place]…

Comments are closed.

Skip to main content