How to pass dynamic parameter value to data adapter URL in jasper

Hi All,

I have a subreport which is populating data using json url.

for json URL i am using a data adapter and subreport is also sing same.

Below is my data adaapter file.

<?xml version="1.0" encoding="UTF-8" ?>
<jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl">
    <name>Remote_JSON_Data_Adapter </name>
    <dataFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:type="httpDataLocation">
        <method>GET</method>
        <url>http://xxx.com/api/v1/pricelists/</url>
        <username>techUser</username>
        <password>mDNWqaff7sRmbwqQ8m</password>
    </dataFile>
    <language>json</language>
    <useConnection>true</useConnection>
    <timeZone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:java="http://java.sun.com"
              xsi:type="java:java.lang.String">
        Asia/Calcutta
    </timeZone>
    <locale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:java="http://java.sun.com"
            xsi:type="java:java.lang.String">
        en_IN
    </locale>
    <selectExpression></selectExpression>
</jsonDataAdapter>

and in subreport using data dapter property:

<property name="net.sf.jasperreports.data.adapter" 
          value="repo:/PID/Remote_JSON_Data_Adapter"/

My question is.

how i can pass a ID to data adapter from subreport like below:

so that url can be formed like : http://xxx.com/api/v1/pricelists/{ID}.

Please help

sushobhan.b's picture
Joined: Aug 22 2018 - 10:52pm
Last seen: 1 year 10 months ago

Amazing how such a basic thing like this has no official answer. Almost every API needs passing anonymous parameters separated by /

gustavofarias - 2 months 3 weeks ago

2 Answers:

HI
have a look at this, there is note at bottom it may help
https://community.jaspersoft.com/questions/1107291/traversing-json-outpu...

I am currenly also trying to get my report to work with dynamic URL

zeldakr's picture
115
Joined: Oct 7 2019 - 6:20am
Last seen: 2 years 7 months ago
fatandaz's picture
Joined: May 7 2021 - 3:24am
Last seen: 1 year 9 months ago
Feedback