Java Rest_v2 execution Report doesn't produce the pdf file

Hi to all,
I have created a report using TIBCO Jaspersoft Studio named report_con_query_interna.jrxml
Then I've deployed it on Jasper Server running on my PC and path and ID resource are:
Path: /reports/ReportConQuerySuDatabase
ID resource: ReportConQuerySuDatabase
Now I have created a client JAVA that executes the report.
The Java code is:
public String executeReport() {
        String REPORT_RAW = "{\"reportUnitUri\":\"/reports/ReportConQuerySuDatabase\", \"async\":\"true\", \"freshData\":\"true\", \"saveDataSnapshot\":\"true\", \"outputFormat\": \"pdf\", \"interactive\":\"true\", \"ignorePagination\":\"false\"}";
System.out.println("executing a report");
    //building the request parameters
    List<NameValuePair> ce_qparams = new ArrayList<NameValuePair>();
    ce_qparams.add(new BasicNameValuePair("j_username", "jasperadmin"));
    ce_qparams.add(new BasicNameValuePair("j_password", "jasperadmin"));
    try {
    HttpPost httpReqPost = new HttpPost();
    // set header
    httpReqPost.setHeader("Accept", "application/json");
    httpReqPost.setHeader("Content-type", "application/json");
    HttpEntity entity = new ByteArrayEntity(REPORT_RAW.getBytes("UTF-8"));
    String result = getStringFromInputStream(entity.getContent());
    System.out.println("payload: " + result);
    httpRes = sendRequest(httpReqPost, RESOURCE_REPORT_EXECUTIONS, ce_qparams, true);
    System.out.println("http response: " + httpRes.toString());
    result = getStringFromInputStream(httpRes.getEntity().getContent());
    System.out.println("descriptor: " + result);
    return result;
    catch (Exception e) {
return null;
System.out.println are:
payload: {"reportUnitUri":"/reports/ReportConQuerySuDatabase", "async":"true", "freshData":"true", "saveDataSnapshot":"true", "outputFormat": "pdf", "interactive":"true", "ignorePagination":"false"}
http response: HTTP/1.1 200 OK [Server: Apache-Coyote/1.1, P3P: CP="ALL", Set-Cookie: userLocale=en_US;Expires=Wed, 3-Feb-2016 16:19:31 GMT;HttpOnly, Content-Type: application/json, Transfer-Encoding: chunked, Date: Tue, 02 Feb 2016 16:19:31 GMT]
descriptor: {"status":"queued","requestId":"960ba085-ce1e-44ff-a972-bb4489f38710","reportURI":"/reports/ReportConQuerySuDatabase","exports":[{"id":"f5d091d8-be7d-476a-a00b-f5f41cae2dcb","status":"queued"}]}
Where is saved the file pdf produced by the execution of this report ?
f.bonavia's picture
Joined: Jan 26 2016 - 11:48pm
Last seen: 7 years 3 months ago

1 Answer:

You should use the java rest client which would make your life easier :

plambert_1's picture
Joined: May 21 2013 - 10:18am
Last seen: 4 years 7 months ago