Requirement:
Since that the Webservice-Plugin (https://community.jaspersoft.com/files/file/37-web-service-data-source/) is no longer supported in Jaspersoft Studio 8.2.0, we are trying to get the same results with a JSON data adapter.
For example, in this public web service URI, https://api.predic8.de/shop/v2/products/, we need to make the URI dynamic so that the endpoint (...v2/products/1, v2/products/2, v2/products/3) can be changed by an input using a report parameter, like:
https://api.predic8.de/shop/v2/products/$P{Parameter}
where $P{Parameter} should substitute to 1 or 2 or 3 using a report parameter.
GET https://api.predic8.de/shop/v2/products/1 or
GET https://api.predic8.de/shop/v2/products/2 or
GET https://api.predic8.de/shop/v2/products/3
Is it possible to use a report parameter to override the URI in a JSON data adapter like above?
Solution:
We can define a parameter in the report whose value overrides the URI in the JSON data adapter.
e.g. <parameter name="DataURI" class="java.lang.String" isForPrompting="false" evaluationTime="Early"> <property name="net.sf.jasperreports.http.data.url"/> <defaultValueExpression>"https://api.predic8.de/shop/v2/products/" + $P{Parameter}</defaultValueExpression> </parameter>
Please see - https://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.http.data.url
Attached are the Sample report.jrxml and the Sample adapter.xml which uses the above public web service URI to illustrate and obtain the desired results.
________________________________________________________________________________________________________________________
Ref. Case #02240412
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now