Jump to content

Recommended Posts

Posted

Hi,

I am having a hard time figuring out a pressing issue related to setting input controls via JasperReports Server Web Services. I want to use the web service accessible by http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/path/to/report/inputControls/<ic1>;<ic2>;.../values/ , and I wrote some code closely following the specification of the service (from JasperReports Server Web Services Guide, Release 5.6, pg. 86).

I use Java with Jersey client, and have the following code:

    public static Client login( String username,                                String password ) {               Client client = ClientBuilder.newClient();               //Now setup authentication        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(username,                                                                             password);        client.register(feature);               return client;    }    public static String setInputControls( Client client,                                            String report,                                            String[]... args ) throws Exception {                //Target JasperReports Server, our report        String api_link = "http://localhost:8091/jasperserver-pro/rest_v2/reports/"                        + report + "/inputControls/";               for (String[] arg : args) {            api_link = api_link + arg[0] + ";";        }            api_link = api_link.substring(0, api_link.length() - 1) + "/values/";               WebTarget target = client.target(api_link);                String json_param = "{n";               for (String[] arg : args) {            json_param = json_param + """ + arg[0] + "": [";                       for (int i = 1; i < arg.length; i++) {                json_param = json_param + """ + arg[i] + "", ";            }            json_param = json_param.substring(0, json_param.length() - 2) + "],n";        }        json_param = json_param + "}";                Response response =                  target.request().post(Entity.entity(json_param, MediaType.APPLICATION_JSON));               return "HTTP STATUS: " + response.getStatus() +               "<br><br>" + response.readEntity(String.class);    } [/code]

to run the program as follows

Client client = login("jasperadmin", "jasperadmin");return setInputControls( client, report, new String[] {"week_1", "9", "15", "27",                                                                 "11"},                                         new String[] {"day_name_1", "friday "} )[/code]

The code seems to do exactly what it is supposed to do, but when I download the report I tried to change the input control values of, I always get the same old version with the default input control values. Even though my query always returns HTTP status 200 and a renewed JSON of input control values, exactly as it should on success.

What did I do wrong? I have spent almost a day trying to figure it out, but the code seems to do what it should...

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