REST API Application Examples

With the REST API interface of the combit Report Server (Enterprise Edition), you can access Report Server functions even from within your own applications developed in-house (no matter what platform or programming language). In doing so, the combit Report Server simply works as a separate reporting component for your other programs. The following programming examples are documented in the manual and show 2 methods out of many for accessing the REST API interface. One option is to use a command line tool (curl). Another option is to use the Windows app, which is available as free download (for Windows 8.1 & 10) in the Windows App Store. A JavaScript code sample makes it clear.

Documentation of the REST API application examples is available in the manual: Manual of the Business Intelligence Solution

1. Access and save reports using the command line tool (curl)

By accessing the REST API interface using the command line tool (curl), reports can be accessed from almost any platform. In our example, the report template with the ID:2551186E-F854-4D1A-ACAE-8ABA02241AE2 is simply accessed as a PDF and saved as salesreport.pdf with this method.

curl "https://combitreportserver/api/v1/report/2551186E-F854-4D1A-ACAE-8ABA02241AE2/export?clientid=apiuser123&clienttoken=abc" > salesreport.pdf


2. Using the Windows app to access reports

The combit Report Server Client Windows app (for Windows 8.1 & Windows 10) was programmed with less than 700 lines of code and also uses the REST API interface to manage and display your reports.


 


3. JavaScript code sample

The JavaScript code sample shows how a report can be exported via a predefined export profile and displayed in the browser.

var host = 'http://myreportserver/rs';

// Define authentication parameters
// When requesting the exported files, do not forget to also set the authentication parameters (or headers).
var clientId = 'apiuser1';
var clientToken = 'fChzVBFn3sdibvRx5xq9BBiabxsR4uhK';
var authParameters = '&clientid=' + clientId + '&clienttoken=' + clientToken;

// Set the desired report and report output format
var templateID = '2551186E-F854-4D1A-ACAE-8ABA02241AE2';
var exportProfileID = 'F8786F1D-CF4D-4B9D-9EB5-A01ED7375A4E';

// Get object with links to exported files (resulttype=pagelinks)
// and serialize as JSON
var formatParameters = 'resulttype=pagelinks&format=json';

// construct complete URL
var apiUrl = host + '/api/v1/report/' + templateID + '/export/' + exportProfileID 
               + '?' + formatParameters + authParameters;

// Let jQuery handle the JSONP request (datatype = jsonp):
// and insert all exported files in this page
$.ajax({ url: apiUrl, dataType: 'jsonp', jsonp: 'jsonpCallback' })
.done(function( exportResult ) {
    for (var i=0; i < exportResult.FileUrls.length; i++) {
      var imgSrc = exportResult.FileUrls[i] + '?' + authParameters;   // authParameters are required again!
        $('body').append('<img src="' + imgSrc + '" />');
    }
})
.fail(function(xhr, textStatus, errorThrown) {
    window.alert(object);
});

 

Last update: 2017-10-26
+1 800 256 3608 (toll-free North America only)