7.11. Executing Reports via the URL

If you wish to integrate reports in external applications, you can use a specific URL to directly link the report export.

http://SERVER:PORT/reportserverbasedir/reportserver/reportexport

Here the following parameters control the export:

id Specifies the report (also refer to key).
p_ Can be used to specify parameters. After the underscore character, the parameter will be prompted by its key. p_myparameter=abc|def, for instance, can be used to set a list parameter to abc and def.
key As an alternative to id, key can be used to select reports.
format Defines the output format. Valid output formats are: EXCEL, CSV, PDF, XML, WORD, XLS, RTF, PNG, JSON, JSONC (for compact JSON export), SAIKU_CHART_HTML, TABLE_TEMPLATE, and RS_SIMPLE_BEAN.
page Allows to export a single page.

Depending on the format, additional properties are available.

TABLE_TEMPLATE The template to be used needs to be specified via its ID as tabletemplate_id or via its key as texttt{tabletemplate_key}.
csv The delimiter is controlled via csv_sep, the quote character can be specified via csv_q. Additionally, you can control whether or not to print a header line via the property csv_ph.
7.11.1. Particularities of the Dynamic List

In addition to the control options stated above, you can set further properties for dynamic lists:

pagesize Defines the pagesize to be used when exporting single pages. For example &page=2&pagesize=10 will select records 11 to 20.
c_1 For dynamic lists this option specifies the columns to output. Separated by the pipe symbol, an alias can be entered. The figure following the underscore specifies the sequence. c_2=ID|fooID specifies the second column to be the ID column with the alias fooID.
allcolumns Can be specified instead of c_ to select all columns (true/false)
ac_1 Like c_1, however, this option selects a computed column.
agg_i Sets an aggregation for column i. Admissible values are: AVG, COUNT, MAX, MIN, SUM, VARIANCE, COUNT_DISTINCT
h_i Hides the i-th column
or_i Controls i-th column sorting. Admissible values are: ASC (ascending), DESC (descending).
fi_i Allows to define inclusion filters for the i column. Multiple filter values can be separated by the pipe (|) symbol. Here you will find an example for a configuration: fi_1=FILTER_A|FILTER_B|FILTER_C
fri_i Allows to define inclusion filter sections for the i-th column. Multiple sections will be separated by the pipe (|) symbol. To separate the section use space-dash-space ("-"), as it is known from the filter dialogue. Additionally, to define open intervals, start the filter with "-⎵" or end it with "⎵-" (where ⎵ denotes a space).
fe_i Like fi_ however, it defines an exclusion filter.

Here you will find an example for a possible configuration (spaces in URLs will be coded as %20, further information on URL encoding you wilL find, for instance under http://www.w3schools.com/tags/ref_urlencode.asp):

https://127.0.0.1:8888/reportserver/reportserver/reportexport?id=4&c_1=ENTITY_ID|FOO_ID&fri_1=2\%20-\%205|-\%207&c_2=action&c_3=key_field&h_1&or_1=DESC&format=pdf

7.11.2. Configuring Reports in ReportServer by URL

In addition to exporting reports by URL, you can directly open pre-configured reports in ReportServer by URL. Here the URL is

https://SERVER:PORT/reportserverbasedir/ReportServer.html#reportexec/

Here you can use the above parameters to pre-configure the report. Please keep in mind to separate parameters from the appurtenant value by setting a colon (:) (instead of using the equal sign "=").

The above parameters are supplemented by "v:preview" to directly jump to the preview. Here we give you an example for a possible configuration:

https://SERVER:PORT/reportserverbasedir/ReportServer.html#reportexec/key:customer&c_1:CUS_CUSTOMERNUMBER&c_2:CUS_CUSTOMERNAME&c_3:CUS_ADDRESSLINE1&c_4:CUS_ADDRESSLINE2&c_5:CUS_CITY&fi_1:187&v:preview

7.11.3. Embedding Reports Without Login

In some cases it is helpful to execute reports without having to login first. Here ReportServer's solution is an easy-to-use servlet. The httpauthexport servlet allows to execute reports without the user being logged in. The URL to be used is:

https://SERVER:PORT/reportserverbasedir/reportserver/httpauthexport

Apart from the usual parameters, you have to enter

user User name
apikey An apikey that is defined as a user property
Define the API Key and Define Appropriate Permissions

To define an API key for a user go to the user management view and select the user in question. Then select the tab User Properties and add a new property called apikey. As value, you can use any string (preferably a random string that is on the longish side).

Note that the apikey can be found as plain text in the URL, so make sure you use HTTPS. Treat the apikey like any password.

The user does not require a password, or any unusual permissions. The only permissions required are the execute permission on those reports that you plan to embed. Suppose, that we have specified the apikey 79PKXGScP8r8 on a fresh user exportuser which has no permissions except the permission to execute report 5000. Then, when everything goes right, then

http://SERVER:PORT/reportserverbasedir/reportserver/httpauthexport?id=5000&user=exportuser&apikey=79PKXGScP8r8&format=HTML&download=false

should execute the report with id 5000 and user exportuser.

7.11.4. Embedding the Report Execution View

In the previous section we have seen how to execute reports directly via the URL. It is also possible to detach the report execution view (i.e., including parameter configuration or the complete configuration for dynamic lists) to, for example, embed it into a portal. The syntax is analogous to the reportexec functionality described above. The base URL for embedding the report view is

http://SERVER:PORT/reportserverbasedir/ReportServer.html#inlinereport/

Thus, to display report with id 29 you would use the URL

http://SERVER:PORT/reportserverbasedir/ReportServer.html#inlinereport/id:29

If you only want to display the preview view, then you can add the "type:preview" parameter, that is

http://SERVER:PORT/reportserverbasedir/ReportServer.html#inlinereport/id:29&type:preview

You can even specify exactly which views to display. Assuming that report 29 is a dynamic list, then the following would select the list config as well as the preview

http://rstest.datenwerke.net/ReportServer.html#inlinereport/id:29&views:listconfig|preview

The following views are available

parameter The parameter view.
computedcolumns The computed columns view of dynamic lists.
prefilter The pre filter view of dynamic lists.
listconfig The list configuration view of dynamic lists.
preview The preview view

Note that you can still completely configure the report via the URL as seen in the following example where we configure a dynamic list:

http://SERVER:PORT/reportserverbasedir/ReportServer.html#inlinereport/key:customer&c_1:CUS_CUSTOMERNUMBER&c_2:CUS_CUSTOMERNAME&c_3:CUS_ADDRESSLINE1&c_4:CUS_ADDRESSLINE2&c_5:CUS_CITY&fi_1:187&views:preview