SSRS parameters through post method

Roberto Ortega 6 Reputation points
2021-12-07T23:20:14.427+00:00

I can't find in the Microsoft documentation anywhere that SSRS supports using an HTTP post method from a web form. I have tried it and it seems to work for HTML viewer scenarios, but it doesn't render as PDF or Excel when I change the rs:Format parameter. It would be great to find that MS actually supports POST rather than its just in there and works for some scenarios. Also, I wonder if using a <form> element at all is supported. I see MS documentation for URL method, which is of course the GET method, but nothing officially documented that POST works and no official examples of <form> elements with method=POST or even method=GET. I found that the browser <form> elements with method=GET mangle the action location because the action already contains the name of the report definition file like this:
action="https://ssrs_server/ReportServer2016/Pages/ReportViewer.aspx?/myfolder/mysubfolder/MyReportByCountry"

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,061 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Roberto Ortega 6 Reputation points
    2021-12-09T04:25:37.57+00:00

    The POST method doesn't work. I instead formed a full URL from the parameters with this code:

            function getFullUrlWithParams(formId) {
                var $form = $("#" + formId);
                var paramsArr =  $form.find(":input[name]").map(function (val, key) {
                    //all input fields must have a name
                    return encodeURIComponent($(this).attr('name'))
                        + '='
                        + encodeURIComponent($(this).val()).replace(/%2C/g, ',').replace(/%20/g, ' ');
                    //unencode space and comma characters for convinience and shorter URLs
                }).get();
                var urlBuilder = $form[0].action;
                urlBuilder += urlBuilder.includes('?') ? '&' : '?';
                urlBuilder = urlBuilder.replace('&&', '&').replace('??', '?'); //in case these chars were at the end, replace() will only do one, which is fine
                urlBuilder += paramsArr.join("&");
                return urlBuilder;
            }
    
    1 person found this answer helpful.
    0 comments No comments

  2. Joyzhao-MSFT 15,631 Reputation points
    2021-12-08T02:22:39.823+00:00

    Hi @Roberto Ortega
    URL access in Reporting Services is specifically designed to enable access to individual reports over a network. This type of access is best for integrating report viewing and navigation into a custom Web application. To use URL access in Web applications, you can:

    • Address a URL to a specific report server from a Web site or portal.
    • Use a form POST method and pass query string parameters to a report server URL using form fields.

    Internet Explorer has a maximum URL length of 2,083 characters. This limit applies to both POST and GET request URLs. POST, however, is not limited by the size of the URL for submitting name/value pairs as part of a form, because they are transferred in the header and not the URL.

    For more information. please see: URL Access Through a Form POST Method.

    Microsoft SQL Server 2017 Reporting Services support Representational State Transfer (REST) APIs. The REST APIs are service endpoints that support a set of HTTP operations (methods), which provide create, retrieve, update, or delete access for resources within a report server.

    Reporting Services REST APIs support DELETE, GET, HEAD, PUT, POST, and PATCH methods.

    A REST API request/response pair can be separated into five components:The request URI; HTTP request message header fields; Optional HTTP request message body fields, to support the URI and HTTP operation; HTTP response message header fields; Optional HTTP response message body fields.

    For more information, please see: Develop with the REST API for Reporting Services.

    If you use the Report Viewer control and there is no report server locally, you will not be suitable to use url access and use Rest API to access the report server.

    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.