JRPRINT Output format throws a 404 using REST

 Hi,

I am quite new to Jasper server, so am struggling with a very basic problem here:

I am able to fetch the list of resources under a folder from the repository and then make a PUT request to get a report. Once I get the UUID of the report, I make a GET request to run the report and get the output. However, that throws a 404 to me. Please see the code and my logs below:

 

 

My logs show:

 

URI:http://host1:8080/jasperserver-pro/rest/report/Test/SingleChart?RUN_OUTPUT_FORMAT=JRPRINT

URI HERE IS:http://host1:8080/jasperserver-pro/rest/report/Test/SingleChart?RUN_OUTPUT_FORMAT=JRPRINT

Response status line:HTTP/1.1 201 Created

SS - Get the RDs: <report>

<uuid>158abadc-db7c-4d3b-b2ab-42ffcc83e304</uuid>

<originalUri>/Test/SingleChart</originalUri>

<totalPages>1</totalPages>

<startPage>1</startPage>

<endPage>1</endPage>

<file type="application/octet-stream"><![CDATA[jasperPrint]]></file>

</report>

**************

-----ReportUUid:158abadc-db7c-4d3b-b2ab-42ffcc83e304

URI:http://host1:8080/jasperserver-pro/rest/report/158abadc-db7c-4d3b-b2ab-42ffcc83e304?file=report

sending Request. url: http://host1:8080/jasperserver-pro/rest/report/158abadc-db7c-4d3b-b2ab-42ffcc83e304?file=report req verb: GET

response status line: HTTP/1.1 404 Not Found

-----statusCode:404

Download failed: HTTP/1.1 404 Not Found

 

Can someone help me figure out what I'm doing wrong?

 

Thanks!

 

Code:
httpReq = new HttpPut();
 
reqEntity.setContent(new ByteArrayInputStream(requestXml.getBytes()));
reqEntity.setContent(new ByteArrayInputStream(requestXml.getBytes()));
((HttpEntityEnclosingRequestBase) httpReq).setEntity(reqEntity);
 
URI uri = createURI("/report/Test/SingleChart?RUN_OUTPUT_FORMAT=JRPRINT", null, false);			
httpReq.setURI(uri);
httpRes = httpClient.execute(httpReq, httpContext);
System.out.println("Response status line:"+httpRes.getStatusLine());
 
String responseReportRD = EntityUtils.toString(httpRes.getEntity());
 
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = domFactory.newDocumentBuilder();
StringReader sr = new StringReader(responseReportRD);
InputSource is = new InputSource(sr);
Document xmlDoc = builder.parse(is);
 
//Extracting the report's UUID
NodeList nodes = xmlDoc.getElementsByTagName("uuid");
String reportUuid = nodes.item(0).getTextContent();
System.out.println("-----ReportUUid:"+reportUuid);
 
//Setting GET request to download the report
String reportFileURL = "http://host1:8080/jasperserver-pro/rest/report/"+reportUuid+"?file=report";
httpReq = new HttpGet();
httpRes = sendRequest(httpReq, "/report/"+reportUuid+"?file=report");
 
//Send GET request to download the report
System.out.println("-----statusCode:"+httpRes.getStatusLine().getStatusCode());
 



Post Edited by javafreak at 06/14/2012 18:58



Post Edited by javafreak at 06/14/2012 19:18
javafreak's picture
175
Joined: May 9 2012 - 12:00pm
Last seen: 11 years 4 months ago

1 Answer:

Found the issue...I am using file=report instead of file=jasperPrint. It works fine when I set the parameter file as jasperPrint.
javafreak's picture
175
Joined: May 9 2012 - 12:00pm
Last seen: 11 years 4 months ago
Feedback
randomness