Search code examples
jasperserver

How to change data source of report in jasper server using rest service


I am new to Jasper Server. I have successfully created a simple report and pushed it to server and I am able to run it through rest service using postman. Now my next requirement is to change data source of report so that we can have advantage of using same report with different data. I have searched but could not find a working answer. I am using jasper server 8.0.I would appreciate a solution that would work with postman


Solution

  • First we need to get the descriptor of file whose data source we want to change. Descriptor basically describes our file in server.

    Make a “GET” call to the link http://:/jasperserver/rest_v2/resources/reports/ path/to/report and set headers to

    Content-Type: application/repository.file+json Accept: application/json

    Copy the returned json (descriptor)

    Now make a “PUT” call to the link http://:/jasperserver/rest_v2/resources/reports/ path/to/report

    and set headers to (very important)

    Content-Type: application/repository.reportUnit+json Accept: application/json

    And inside body paste the descriptor you copied and change the things you want. and send it.