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".
1 Answer:
Posted on December 8, 2014 at 8:14am
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:
Attachment | Size |
---|---|
![]() | 2.44 KB |
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?
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