Jump to content
We've recently updated our Privacy Statement, available here ×

How to Execute the report to jasper server by REST v2 - /rest_v2/reports/reports/


Judes

Recommended Posts

Hi,

Recently we have migrated the japser sever 5.2 to 7.8.

Now we are changing the rest api call rest to rest_v2 and have changed the login and get report resource rest call based on the rest_v2.

ClientConfig config = new ClientConfig();
BasicAuthSecurityHandler basic = new BasicAuthSecurityHandler();
basic.setUserName(jasperadmin);
basic.setPassword(jasperadmin);
config.handlers(basic);
config.acceptHeaderAutoSet(true);

1. Rest Api : Login to Jasper Server

Resource resource = client.resource("http://localhost:8080/jasperserver"+ "/rest_v2/login");
 response = resource.contentType("application/x-www-form-urlencoded").accept("text/plain").post(loginStr);

2.  Get report resource for the given report name

resource = client.resource("http://localhost:8080/jasperserver" + "/rest_v2/resources/reports/" + "PM/test");
resource.header("Cookie", cookieString).header("Access-Control-Allow-Origin", "*");          
resource.accept("application/xml");
response = resource.contentType("text/plain").get();

3.Execute the report

resource =client.resource("http://localhost:8080/jasperserver"+ "/rest/reports/reports/" + reportName + "?RUN_OUTPUT_FORMAT=" + format);
resource.header("Cookie", cookieString);
resource.accept("application/xml");
response = resource.contentType("text/xml").put(xmlToString(doc));

doc = parseXMLMessage(response.getEntity(String.class));
NodeList nList = doc.getDocumentElement().getElementsByTagName("uuid");

4. Retrieve the report content

String uuid = nList.item(0).getTextContent();
resource = client.resource("http://localhost:8080" + "/rest/report/" + uuid + "?file=report");
resource.header("Cookie", cookieString);
response = resource.get();

we can able to run Step 1 and Step 2 successfully but step 3 while runing got 405 error.

Step 3 - How to call the rest api and how to put the XML content to jasper server.

Kindly assist me provide solution for how to implement the step 3 and step 4 using rest_v2 rest api call .

 

Regards,

Judes

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

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