Chapter 11. REST API

11. REST API

ReportServer publishes several REST API endpoints automatically which can be used for accessing given REST services.

11.1. Finding the REST URL

You can find the main REST endpoint of your ReportServer in the ''General Info'' system console. Here, you can find a ''REST URL'' entry which displays the complete URL to your REST endpoint. An example is given below.

REST URL: https://SERVER:PORT/reportserverbasedir/reportserver/rest

Having this base URL it is easy to append the services described below to access the specific REST services available.

Note that spaces in URLs will be encoded as

11.2. Authentication

REST API authentication uses an apikey analogously as in executing reports via URL (see Section 7.11.). Once you set an apikey for a given user, you can access all REST services using this apikey in the URL, e.g. for the ''general-info'' REST service:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/general-info?user=myuser&apikey=MYAPIKEY

In the example above, the user authenticated is myuser and the apikey is MYAPIKEY.

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.
11.3. test Service

The test REST service issues a test request which allows you to make sure the REST endpoint is correct and available.

The syntax is:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/test?user=myuser&apikey=MYAPIKEY

11.4. general-info Service

The general-info REST service returns a JSON containing your system configuration. Basically, it contains all data available in the ''General Info'' system console.

The syntax is:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/general-info?user=myuser&apikey=MYAPIKEY

11.5. dot-renderer Service

The dot-renderer REST service allows you to render a Graphviz DOT file (https://graphviz.org/doc/info/lang.html) into a SVG file which can be displayed directly by your web browser.

The syntax is:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?user=myuser&apikey=MYAPIKEY

11.5.1. Virtual Filesystem / Internal Files

In order to render internal files you need to make a GET request and must specify an additional query variable path, which points to the DOT file in your ReportServer virtual filesystem, in this case to /fileserver/resources/graph.dot.

(GET) https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?path=/fileserver/resources/graph.dot&user=myuser&apikey=MYAPIKEY

11.5.2. External Files

In order to render arbitrary external data you need to make a POST request and use the request body to specify the dot-data you want to render in plain text.

(POST) https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?user=myuser&apikey=MYAPIKEY

Don't forget to include your external DOT file in your POST request body.

11.5.3. Customizing Output

An optional width parameter may be used to change the SVG file's width. Default is 1200.

(GET) https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?path=/fileserver/resources/graph.dot&width=900&user=myuser&apikey=MYAPIKEY

(POST) https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?width=900&user=myuser&apikey=MYAPIKEY

An optional wrap_html parameter may be used to wrap the SVG output with an empty header and a body in which the result is embedded. By default this option is set to false. Be aware of the fact that this option changes the content type from image/svg+xml to text/html!

(GET) https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?path=/fileserver/resources/graph.dot&user=myuser&apikey=MYAPIKEY&wrap_html=true

(POST) https://SERVER:PORT/reportserverbasedir/reportserver/rest/dot-renderer?user=myuser&apikey=MYAPIKEY&wrap_html=true

11.6. markdown-renderer Service

The markdown-renderer REST service allows you to render a markdown file (https://www.markdownguide.org/) to an HTML representation. While most markdown commands are supported, there are exceptions which cannot be translated directly to HTML and will not be rendered properly.

The syntax is:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/markdown-renderer?user=myuser&apikey=MYAPIKEY

11.6.1. Virtual Filesystem / Internal Files

Similar to dot-renderer, in order to render internal files you need to make a GET request and must specify an additional query variable path, which points to the markdown file in your ReportServer virtual filesystem, in this case to /fileserver/resources/example.md.

(GET) https://SERVER:PORT/reportserverbasedir/reportserver/rest/markdown-renderer?path=/fileserver/resources/example.md&user=myuser&apikey=MYAPIKEY

11.6.2. External Files

In order to render arbitrary external data you need to make a POST request and use the request body to specify the markdown-data you want to render in plain text.

(POST) https://SERVER:PORT/reportserverbasedir/reportserver/rest/markdown-renderer?user=myuser&apikey=MYAPIKEY

Don't forget to include your external markdown file in your POST request body.

11.6.3. Customizing Output

An optional wrap_html parameter may be used to wrap the HTML output with an empty header and a body in which the result is embedded. By default this option is set to false.

(GET) https://SERVER:PORT/reportserverbasedir/reportserver/rest/markdown-renderer?path=/fileserver/resources/example.md&user=myuser&apikey=MYAPIKEY&wrap_html=true

(POST) https://SERVER:PORT/reportserverbasedir/reportserver/rest/markdown-renderer&user=myuser&apikey=MYAPIKEY&wrap_html=true

11.7. node-exporter Service

The node-exporter REST service allows you to export any node to XML in an analogous way as the ''export'' functionality described in Section 10. Along with the XML export, some metadata is displayed in the JSON file.

The syntax is dependent on the specific node being exported and will be described in the following subsections. All nodes support a flatten parameter. If this parameter is set to true, all objects exported are flattened, i.e. all folders are stripped off.

As an example, consider exporting all reports with the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/reportmanager/;flatten=true?user=myuser&apikey=MYAPIKEY

You can always use the terminal for finding out the exact path of the node you want to export. Just navigate to the node you to export and enter the pwd command as described in Section 19.50.

11.7.1. Exporting reports

The node-exporter service can be used to export reports or report directories using the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/reportmanager/myreports/myreport?user=myuser&apikey=MYAPIKEY

where /reportmanager/myreports/myreport is a path to the report being exported. You can also export a complete report directory, e.g. /reportmanager/myreports.

An optional includeVariants parameter is used to export variants along with the base reports. Default is false:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/reportmanager/myreports/myreport?includeVariants=true&user=myuser&apikey=MYAPIKEY

11.7.2. Exporting users

The node-exporter service can be used to export users, groups or organizational units using the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/usermanager/ClassicModelCars/myuser?user=myuser&apikey=MYAPIKEY

where /usermanager/ClassicModelCars/myuser is a path to the user or group being exported. You can also export a complete organizational unit, e.g. /usermanager/ClassicModelCars.

11.7.3. Exporting datasources

The node-exporter service can be used to export datasources or datasource directories using the following syntax (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://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/datasources/internal\%20datasources/ReportServer\%20Data\%20Source?user=myuser&apikey=MYAPIKEY

where /datasources/internal datasources/ReportServer Data Source is a path to the datasource being exported. You can also export a complete directory, e.g. /datasources/internal datasources.

11.7.4. Exporting datasinks

The node-exporter service can be used to export datasink or datasink directories using the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/datasinks/mydirectory/mydatasink?user=myuser&apikey=MYAPIKEY

where /datasinks/mydirectory/mydatasink is a path to the datasink being exported. You can also export a complete directory, e.g. /datasinks/mydirectory.

11.7.5. Exporting files

The node-exporter service can be used to export files or file directories from the virtual file system using the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/fileserver/mydirectory/myfile.groovy?user=myuser&apikey=MYAPIKEY

where /fileserver/mydirectory/myfile.groovy is a path to the file being exported. You can also export a complete directory, e.g. /fileserver/mydirectory.

11.7.6. Exporting remote servers

The node-exporter service can be used to export remote servers or remote server directories using the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/remoteservers/mydirectory/myremoteserver?user=myuser&apikey=MYAPIKEY

where /remoteservers/mydirectory/myremoteserver is a path to the remote server being exported. You can also export a complete directory, e.g. /remoteservers/mydirectory.

11.7.7. Exporting transports

The node-exporter service can be used to export transports or transport directories using the following syntax:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/transports/mydirectory/mytransport?user=myuser&apikey=MYAPIKEY

where /transports/mydirectory/mytransport is a path to the transport being exported. You can also export a complete directory, e.g. /transports/mydirectory.

Note that if you are exporting a specific transport, you have to enter its key. E.g.:

https://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/transports/mydirectory/a5f9000b91ea0a85c3ab8a9a35cbec65aa1a609a?user=myuser&apikey=MYAPIKEY

where a5f9000b91ea0a85c3ab8a9a35cbec65aa1a609a is the transport's key.

11.7.8. Exporting dashboards from dashboard library

The node-exporter service can be used to export dashboards or dashboard library directories using the following syntax (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://SERVER:PORT/reportserverbasedir/reportserver/rest/node-exporter/dashboardlib/mydirectory/Demo\%20Dashboard?user=myuser&apikey=MYAPIKEY

where /dashboardlib/mydirectory/Demo Dashboard is a path to the dashboard being exported. You can also export a complete directory, e.g. /dashboardlib/mydirectory.