Schedule a report using rest_v2 and java

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));
        // 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 [] generating sample report with parameters and scheduling
INFO [] sending Request. url: http://localhost:8080/jasperserver/rest_v2/jobs/?schedule=%3C%3Fxml+vers...
 INFO [] req method: PUT
 INFO [] response status line: HTTP/1.1 302 Temporarely moved
Exception in thread "main" java.lang.AssertionError: could not generate report
    at org.junit.Assert.assertTrue(

jbgauche57's picture
Joined: May 21 2013 - 12:23am
Last seen: 9 years 7 months ago

1 Answer:

can you post the contents of your xml? (i've posted as an answer because I couldn't find the comment button)

felipegdr's picture
Joined: Apr 20 2012 - 3:51am
Last seen: 6 years 1 month ago