f.bonavia Posted February 2, 2016 Share Posted February 2, 2016 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); httpReqPost.setEntity(entity); //System.out.println("RESOURCE_REPORT_EXECUTIONS: " + RESOURCE_REPORT_EXECUTIONS); 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) { e.printStackTrace(); 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 ? Thanks, Francesco Link to comment Share on other sites More sharing options...
Solution plambert_1 Posted February 14, 2016 Solution Share Posted February 14, 2016 You should use the java rest client which would make your life easier : https://github.com/Jaspersoft/jrs-rest-java-client Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now