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 "http://127.0.0.1:8080/testrestservice".   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 "http://127.0.0.1:8080/testrestservice?name=Jack".

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)

Attachments: 
AttachmentSize
Binary Data json_report_2.jrxml2.44 KB
ernestoo's picture
18956
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">
<defaultValueExpression><![CDATA["12"]]></defaultValueExpression>
</parameter>
<parameter name="net.sf.jasperreports.json.source" class="java.lang.String">
<defaultValueExpression><![CDATA["http://127.0.0.1:8080/candidatemanager/app/rws/misc/test7?locationId=" +$P{locationId}]]></defaultValueExpression>
</parameter>
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
Feedback