JSON Data Adapter / Source REST

I can get the JSON Data Adapter to query a REST service by setting File / URL: in the Jasper Studio Data Adapter wizard to something like "".   But how do you append user provided parameters to the base url so that the url used to acutally retrieve the data would be something like "".

glenmiller's picture
Joined: Dec 3 2014 - 5:15pm
Last seen: 8 years 9 months ago

1 Answer:

Hi there, sorry I don't have much time to explain but looking at this example should help you with a solution (Note that I couldn't get it to preview properly on JSS, only the server)

Binary Data json_report_2.jrxml2.44 KB
ernestoo's picture
Joined: Nov 29 2010 - 11:59am
Last seen: 5 years 11 months ago

Thanks for the example. I am new to Jasper and can't quite figure it all out. I think I am missing some config settings.
The first difference in my tests and you file is I have a
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test REST JSON"/>
that gets inserted by studio.
I have added the follwing
<parameter name="locationId" class="java.lang.String">
<parameter name="net.sf.jasperreports.json.source" class="java.lang.String">
<defaultValueExpression><![CDATA["" +$P{locationId}]]></defaultValueExpression>
To use my rest service, based on what I could see from your example. But it does not seem to be overriding the file / url from the default data adapter being inserted by studio. Everytime I use preview it uses the values set in JSON file Adapter file / url text box. How do I get the url set in the parameter element above to be used instead?

glenmiller - 8 years 9 months ago

Hi Glen, the thing is that when you set the net.sf.jasperreports.json.source "by hand" you should not use the JSON data adapter (because it will effectively over-write it)...you should use --No Data Adapter -- I don't know how to select it but if you don't select one at all it will use no data adapter...I'm on JSS 6.0 btw

ernestoo - 8 years 9 months ago