Jump to content

Schedule a report using rest_v2 and java


jbgauche57

Recommended Posts

Hey everyone,

I'm a student and I have to do a project for the startup I'm working for.

This project is based on JasperReport and I have to integrat this solution in their application.

I have to add the possibility to schedule a report using their interface, using rest_v2.

I've been able to run a report without scheduling but I'm kind of stuck using it with scheduling.

I've build an XML file based on the model generated by the JasperReport Server interface, but I don't know how to use it in my java program.

 

Can somebody help me ?? :)

 

 

 

Here is the interesting part of my program :

// PUT request - schedule  report with an xml job descriptor
        //Gestion fichier XML contenant la schedulisation
        InputStream input = new FileInputStream("C:/workspaces/creer_xml/config_rapport.xml");
        String value = IOUtils.toString(input, "UTF-8");

        List nameValuePairs = new ArrayList();
        nameValuePairs.add(new BasicNameValuePair("schedule", value));
        System.out.println(nameValuePairs);
        
        // contruction de l'url permettant de générer la planification
        final String resourceUri2 = "/jobs/";
        httpRes = restUtils.sendRequest(new HttpPut(), resourceUri2, nameValuePairs, true);    
        

And here is the error it returns :

INFO [com.jaspersoft.jasperserver.rest.sample.RESTV2Test] generating sample report with parameters and scheduling
INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] sending Request. url: http://localhost:8080/jasperserver/rest_v2/jobs/?schedule=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0D%0A%3Cjob%3E%0D%0A%09%3Calert%3E%0D%0A%09%09%3Cid%3E0%3C%2Fid%3E%0D%0A%09%09%3CincludingReportJobInfo%3Etrue%3C%2FincludingReportJobInfo%3E%0D%0A%09%09%3CincludingStackTrace%3Etrue%3C%2FincludingStackTrace%3E%0D%0A%09%09%3CjobState%3EFAIL_ONLY%3C%2FjobState%3E%0D%0A%09%09%3Crecipient%3EOWNER_AND_ADMIN%3C%2Frecipient%3E%0D%0A%09%09%3CtoAddresses%2F%3E%0D%0A%09%09%3Cversion%3E-1%3C%2Fversion%3E%0D%0A%09%3C%2Falert%3E%0D%0A%09%3CbaseOutputFilename%3EEssaiRapportListeNokia%3C%2FbaseOutputFilename%3E%0D%0A%09%3CrepositoryDestination%3E%0D%0A%09%09%3CfolderURI%3E%2Freports%2Fsamples%3C%2FfolderURI%3E%0D%0A%09%09%3Cid%3E2%3C%2Fid%3E%0D%0A%09%09%3CoutputDescription%3Eazertyyy%3C%2FoutputDescription%3E%0D%0A%09%09%3CoutputFTPInfo%3E%0D%0A%09%09%09%3CpropertiesMap%2F%3E%0D%0A%09%09%3C%2FoutputFTPInfo%3E%0D%0A%09%09%3CoverwriteFiles%3Efalse%3C%2FoverwriteFiles%3E%0D%0A%09%09%3CsaveToRepository%3Etrue%3C%2FsaveToRepository%3E%0D%0A%09%09%3CsequentialFilenames%3Etrue%3C%2FsequentialFilenames%3E%0D%0A%09%09%3CusingDefaultReportOutputFolderURI%3Efalse%3C%2FusingDefaultReportOutputFolderURI%3E%0D%0A%09%09%3Cversion%3E0%3C%2Fversion%3E%0D%0A%09%3C%2FrepositoryDestination%3E%0D%0A%09%3CcreationDate%3E2013-05-31T10%3A45%3A08%2B02%3A00%3C%2FcreationDate%3E%0D%0A%09%3Cdescription%3Epif+paf+pouf%3C%2Fdescription%3E%0D%0A%09%3Cid%3E%3C%2Fid%3E%0D%0A%09%3Clabel%3Eencoreun%3C%2Flabel%3E%0D%0A%09%3CoutputFormats%3E%0D%0A%09%09%3CoutputFormat%3EPDF%3C%2FoutputFormat%3E%0D%0A%09%3C%2FoutputFormats%3E%0D%0A%09%3CoutputLocale%2F%3E%0D%0A%09%3CoutputTimeZone%3EEurope%2FParis%3C%2FoutputTimeZone%3E%0D%0A%09%3Csource%3E%0D%0A%09%09%3Cparameters%3E%0D%0A%09%09%09%3CparameterValues%3E%0D%0A%09%09%09%09%3Centry%3E%0D%0A%09%09%09%09%09%3Ckey%3EREPORT_TIME_ZONE%3C%2Fkey%3E%0D%0A%09%09%09%09%09%3Cvalue+xsi%3Atype%3D%22xs%3Astring%22%3EEurope%2FParis%3C%2Fvalue%3E%0D%0A%09%09%09%09%3C%2Fentry%3E%0D%0A%09%09%09%3C%2FparameterValues%3E%0D%0A%09%09%3C%2Fparameters%3E%0D%0A%09%09%3CreportUnitURI%3E%2Freports%2Fsamples%2FEssaiRapportListeNokia%3C%2FreportUnitURI%3E%0D%0A%09%3C%2Fsource%3E%0D%0A%09%3CsimpleTrigger%3E%0D%0A%09%09%3Cid%3E2%3C%2Fid%3E%0D%0A%09%09%3CmisfireInstruction%3E0%3C%2FmisfireInstruction%3E%0D%0A%09%09%3CstartDate%3E2013-05-31T21%3A00%3A00%2B02%3A00%3C%2FstartDate%3E%0D%0A%09%09%3CstartType%3E2%3C%2FstartType%3E%0D%0A%09%09%3Ctimezone%3EEurope%2FParis%3C%2Ftimezone%3E%0D%0A%09%09%3Cversion%3E0%3C%2Fversion%3E%0D%0A%09%09%3CoccurrenceCount%3E1%3C%2FoccurrenceCount%3E%0D%0A%09%3C%2FsimpleTrigger%3E%0D%0A%09%3Cusername%3Ejasperadmin%3C%2Fusername%3E%0D%0A%09%3Cversion%3E0%3C%2Fversion%3E%0D%0A%3C%2Fjob%3E
 INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] req method: PUT
 INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] response status line: HTTP/1.1 302 Temporarely moved
Exception in thread "main" java.lang.AssertionError: could not generate report
    at org.junit.Assert.fail(Assert.java:91)
    at org.junit.Assert.assertTrue(Assert.java:43)
    at com.jaspersoft.jasperserver.rest.sample.RESTV2Test.test(RESTV2Test.java:112)
    at com.jaspersoft.jasperserver.rest.sample.RESTV2Test.main(RESTV2Test.java:47)
 

Link to comment
Share on other sites

  • 3 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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