Jump to content
We've recently updated our Privacy Statement, available here ×

Running a report with REST API


khurram.bilal

Recommended Posts

Hi,

I am new to JASPER. I am trying to use postman to call jasper report before writing a code for the application. Unfortunately the documentation is not explaining the steps needed in a sequence. 

This is the url i am using. http://jrfir01aplxa:8080/jasperserver-pro/rest/login?j_username=username&j_password=pass

I believe valid login is needed. When i use the following URL in postman and provide the credentials i am able to see a response in HTML, which contains

Create Report

To begin creating a report, select an Ad Hoc view.

I feel thats an indication that the login request has been successful. 

Next, i like to call the method to execute the existing report and display in browser. From the documentation https://community.jaspersoft.com/documentation/tibco-jasperreports-server-web-services-guide/v610/running-report-asynchronously-0, 

i have picked this url 

http://MYSERVER:8080/jasperserver-pro/rest_v2/reportExecutions (Is this the correct URL to use??)

Request:

Using PUT in postman

Here is the body in postman that i have added but i get an error

<reportExecutionRequest>    <reportUnitUri>         /organizations/my_company_Reporting/organizations/My_System/Reports/NEW ACCOUNTS    </reportUnitUri>    <async>true</async>    <freshData>false</freshData>    <saveDataSnapshot>false</saveDataSnapshot>    <outputFormat>html</outputFormat>    <interactive>true</interactive>    <ignorePagination>false</ignorePagination>    <pages>1-5</pages>    <parameters>        <reportParameter name="PARAM 2">            <value>###</value>        </reportParameter>        <reportParameter name="PARAM 1">            <value>###</value>        </reportParameter>    </parameters></reportExecutionRequest>[/code]

ERROR:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><errorDescriptor>    <errorCode>serialization.error</errorCode>    <errorUid>1d3bcc3c-07f2-47d4-a902-e66b48522ce5</errorUid>    <message>        There was an error on the server. Try again or contact site administrators.        (Error UID: 1d3bcc3c-07f2-47d4-a902-e66b48522ce5)    </message></errorDescriptor>[/code]

Can anyone review and let me know what will be the correct output that i should be able to get 

Also is there any example in documentation or other wise where it shows a sequence of steps versus a list of methods. 

  1. How to call the report (i believe login is needed, how to tie the login before calling the report) service to execute a rerport

  2. How do we show the response back to the user, Is it like SSRS that it will show up in browser when we define the format is pdf or html?

Thank you.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

I do not about SSRS and I am also learning jasper. So, with the inforamtion you gave:

1 . Check your jasper server logs for more informatin.

2. The error says "serialization.error" that means you are sending wrong data to your report. What are the input controls (PARAM 2, PARAM 1) for the report "NEW ACCOUNT", are you able to run this report directly from jasper server UI ? 

Coming to your question on postman:

How to call the report (i believe login is needed, how to tie the login before calling the report) service to execute a rerport - 

to tie the login in POSTMAN:

1. In the url field paste your server url to reportexecution: http://MYSERVER:8080/jasperserver-pro/rest_v2/reportExecutions 

2. Select the method to "POST"

3. In the authorization tab , select basic auth, enter user name and password

4.  In the headers tab, you may add:

 Key                               Value

Content-Type                  application/xml
Accept                             application/xml
X-REMOTE-DOMAIN   1

note: X-REMOTE-DOMAIN   1 may not be necessary, but try adding it if you get any error.

5. In the body tab, paste your request (xml)

 example: <reportExecutionRequest>
    <reportUnitUri>/reports/interactive/CustomersReport</reportUnitUri>
    <async>true</async>
    <freshData>false</freshData>
    <saveDataSnapshot>false</saveDataSnapshot>
    <outputFormat>html</outputFormat>
    <interactive>true</interactive>
    <ignorePagination>false</ignorePagination>
    <pages>1-5</pages>
</reportExecutionRequest>

6. Send

response should be somthing like :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reportExecution>
    <exports>
        <export>
            <id>33c98001-c0af-41bb-8659-8e44bddc339e</id>
            <status>queued</status>
        </export>
    </exports>
    <reportURI>/reports/interactive/CustomersReport</reportURI>
    <requestId>04e91a83-e9ca-4629-bca9-6e5028f5f6be</requestId>
    <status>queued</status>
</reportExecution>

and then work with export Id and request id and follow : https://community.jaspersoft.com/documentation/tibco-jasperreports-server-rest-api-reference/v630/reportexecutions-service

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...