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

run report in jasperserver with rest web services


aliounedia

Recommended Posts

  • 1 month later...
  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

 Hi Adia,

Hi have exactly the same problem. I run the put request in a REST extension in chrome and I have the same problem

 

Request:

 

PUT http://192.168.1.15:8080/jasperserver/rest/report/reports/test

 

Response:

 

Status code:400

Date: Wed, 08 Feb 2012 23:16:17 GMT 

Connection: close

Content-Length: 27 

Server: Apache-Coyote/1.1 

Cache-Control: private 

Expires: Thu, 01 Jan 1970 01:00:00 CET 

Invalid resource descriptor

 

I am able to run other requests normally. Am I missing something?

 

Thank you!

 

Sergio

Link to comment
Share on other sites

I'll answer to myself,

I managed to run the report. I'll explain what I did. My report is called test.

I found valuable information here:

http://jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=95212

 

1. You must be previoulsy logged (there is a POST request for logging, see the manual) if not you must do basic authorization in each GET, PUT, POST request.

 

2. Run a GET request for getting the reportUnit source descriptor in XML

 

GET http://192.168.1.15:8080/jasperserver/rest/resource/reports/test

 

when this is done, the response is an XML file with the source descriptor for the report "test" (in this case).

 

3. Run a PUT request for generating the report

 

 

Here there is the keypoint that was causing the error: You have to copy the xml text (ENTIRELY) of the previous GET response into the body of the request

 

Optionally, you can add any parameter value by adding anywhere inside the wsType="reportUnit" environment

 

<parameter name="NAME">VALUE</parameter>

 

This is an example (only first lines) of a resource descriptor for tet report where the parameter "a" has been set to 2.

 <resourceDescriptor name="test" wsType="reportUnit" uriString="/reports/test" isNew="false">

<label><![CDATA[test]]></label>
        <parameter name="a">2</parameter>
...

 

The response contains the report UUID

 <report>

<uuid>0d6e3dc7-006c-4f61-b056-b33688c65964</uuid>
<originalUri>/reports/test</originalUri>
<totalPages>1</totalPages>
<startPage>1</startPage>
<endPage>1</endPage>
<file type="application/pdf"><![CDATA[report]]></file>
</report>

 

4. Finally you have to run a get request to load the resulting report file. You hace to use the UUID provided in previous step

 

GET http://192.168.1.15:8080/jasperserver/rest/report/0d6e3dc7-006c-4f61-b056-b33688c65964?file=report

 

This can be done from any webbrowser, the report in pdf should load.

 

Hope it helps!!

Cheers!

Sergio

 

Link to comment
Share on other sites

 I am not sure I understand how to format the request body.  I am a bit of newb with this stuff and am working with creating a custom REST client in my Rails app.

I am able to get the resource for the report, but what exactly am I doing in the HTTP request to the report service with it?  Is it a field value that gets set in the put request?

Link to comment
Share on other sites

  • 6 months later...

 Hi Marco and cpuguy83,

I'm not an expert but I guess that you need to send HTTP comands through the net and manipulate responses. It depends on the language you use. For example, I'm using PHP, and I use curl for constructing and sending http commands (get and put).

http://es.php.net/manual/en/book.curl.php

Similar libraries should exist in other languages as Java.

So, what you need is to construct your GET command, send it and store the response. Then you have to include that response directly in the body of the PUT command,

Take a look to this thread. It also includes some wokring code in PHP.

http://jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=94269

If you do not modify the file descriptor, Jasperserver will create a report with default parameters (if any in the report). If you want to specify some values for the report you must modify the xml file descriptor using some XML manipulator library. For example in PHP take a look at:

http://developer.yahoo.com/php/howto-parseRestPhp.html

I don't know for other languages but the pilosophy should be similar.

Cheers!

Sergio

Link to comment
Share on other sites

  • 9 months later...
  • 1 year later...

First of all I want to thank Sergio for his help, I followed the steps and that worked perfectly to export an HTML report. But when I tried to export a PDF one, the PDF downloaded is Blank. But the number of pages in that PFD file is the same as when I export the report in Ireport or Jasperserver.

Do you have an idea how to get the PDF report generated?

thanks,

Assia

 

 

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...