4

I have a report which receives a List parameter to use it in a IN clause:

$X{IN, personID, _personID}

The report works when running it through the web application or remote repository view in iReport.

Now I need to call it using the REST api. I have tried several different ways of passing the list value in my resource descriptor but none of them worked.

<resourceDescriptor name="Test_Report" wsType="reportUnit" uriString="/Test/Test_Report" isNew="false">

    <parameter name="_personId" isListValue="true"><![CDATA[1]]></parameter>

</resourceDescriptor>

The above example returns the following error:

Invalid type java.lang.String for parameter _personId used in an IN clause; the value must be an array or a collection.

I have also try the following:

<parameter>
<name>_personId</name>
<value isListValue="true">
    3
</value>
</parameter>

But this returns a report with all the records, not only the person with Id=3.

Felipe Reis
  • 479
  • 8
  • 24

2 Answers2

4

My workaround for this problem was to use the REST V2 services of JasperServer.

Added to this the V2 has two advantages over the first version of the service:

  • it doesn't require a resource descriptor
  • it runs and exports the report in a single GET request

All the information required to run and export the report is passed through the request URL, for example:

<host>/rest_v2/reports/Test/TestReport.html?_personId=3&_personId=4&_personId=5&_personId=6

Felipe Reis
  • 479
  • 8
  • 24
1

Your approach is totally fine, but there is also another small tip with collection type arguments ( might be a bug)

  • If you have more than 1 item in the collection this is totally working correctly: (3,4,5,6)->?_personId=3&_personId=4&_personId=5&_personId=6
  • If you have only 1 item in the collection you have to add empty one too: (3)->?_personId=3&_personId=

By the way, I am using Jasper Server CE 7.2.0 on the docker.

Gonzalo Garcia
  • 6,192
  • 2
  • 29
  • 32
Onurus
  • 54
  • 1
  • 4
  • Hi @Onurus, I have your same problem, have you found some solution? Or have you open a ticket on jasperserver project? Thanks! – zaquas Oct 29 '20 at 08:29
  • 1
    Hi @zaquas, No's to both of your questions. Error is originated from if you send just one element, the server tends to evaluate the item as a single item, I found that was an HTTP standard. – Onurus Oct 30 '20 at 11:03
  • Thanks @onurus, I will have to investigate in the jasperserver source :) – zaquas Oct 31 '20 at 12:58