Right Outer Join

7 May 2013

REST endpoint for Jaspersoft Query Executor

Filed under: JasperReports Server — Tags: , , , — mdahlman @ 10:58

Show me the data

Often, usually, nearly-always I want my report server to give me a nicely formatted view of my data. A “report”. But not always. Sometimes I just want my data. I’ll format it myself, thank you. JasperReports Server can do that, but I had never done it before. Here are my notes from figuring it out.


  • JasperReports Server v5.1 or later is installed and working.
  • A data source and a domain are defined.
  • I have at least one query written to get started with.
  • (If you just want to follow along, you can use the sample domain included with JRS and the sample query provided below.)
  • A REST Client for testing. Use whatever you like. I recommend Advanced REST Client (a Chrome plugin).

Construct the URL

Here is the basic structure of the URL we need to create:


In my case I’ll use the sample domain “Supermart Domain”. The URI path is “/public/Samples/Domains/supermartDomain”

Domain URI path

The domain URI path is part of its properties

I constructed a simple query using the Domain Expression Language (domEL) syntax. Refer to the JasperReports Server User Guide for details. Here’s the query in readable form:

    <queryField id="inv_store.inv_store__store_name" />
    <queryField id="inv_store.inv_store__store_type" />
    <queryField id="inv_store__store_contact.inv_store__store_contact__store_manager" />
  <queryFilterString>inv_store__region.inv_store__region__sales_state_province == 'CA'</queryFilterString>

Here’s the same query with spaces and carriage returns removed and url encoded:


With the domain and the query identified, now I have everything I need to construct the url:


I’m ignoring authentication. For a quick test you can first login to JRS, then paste in this url. You’ll get a response in the default format: XML. Refer to the JasperReports Server Web Service Guide for details on how to securely authenticate programmatically.

Show me the data

But I want JSON rather than XML. No problem; I just add the header “Accept: application/json” to my request. Now my result set comes back in JSON.

This screenshot from the Advanced Rest Client shows the added header and the JSON result set.

This screenshot from the Advanced Rest Client shows the added header and the JSON result set.

Why is this cool? Now I have complete flexibility to render the data as I like, but I still get the benefits of the report server:

  • Security: I’ll only see the data that I should see)
  • Scalability: JRS does intelligent data caching
  • Consistency: I’ll continue to use the same data source for most of my data visualizations which get rendered as reports on the server.


  1. is it possible retrive json data from application that uses http POST method for retrieving json data?
    and, is it working on jasperserver community edition?

    Comment by Alex R — 21 May 2013 @ 23:20

    • Yes: in fact under the covers the GET code actually calls the POST method. Both methods will work identically.
      In general the web services work the same in the Community and Commercial editions. But Data Domains (JasperReports Server’s metadata layer) are available only in the commercial editions. So this method doesn’t apply to the community editions of JRS.

      Comment by mdahlman — 25 May 2013 @ 23:38

  2. Is it possible to retrieve json data from a query or report resource (without sending a query as part of the request)? Get the data and format it my self.

    Comment by gidikern — 15 July 2013 @ 01:25

    • Not really. A query object in JRS is really just a way to save a query for re-use. It does not include connection information, so it’s not executable on its own. A report is executable, of course. But there’s no standard JSON export format for the data. It would require a custom exporter to handle that. You could retrieve the query from a query object and submit it as part of the request… that would be useful in several different use cases, but it seems that it’s not exactly what you’re going for.

      Comment by mdahlman — 17 July 2013 @ 12:47

      • Many thanks for your comment.

        Comment by gidikern — 19 July 2013 @ 01:56

RSS feed for comments on this post. TrackBack URI

Go on... leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: