You can take a look at this pentaho site
def reportPentahoServer = "http://localhost:9090/pentaho/content/reporting" // modify it based on your pentaho server location
def username = "user" // modify it based on your pentaho username
def password = "password" // modify it based on your pentaho password
def pentahoQuery = buildQuery(reportParam)
withHttp(uri: reportPentahoServer) {
// this will ensure that the authentication happens before the server asks for credentials
client.addRequestInterceptor(new org.apache.http.HttpRequestInterceptor() {
void process(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext) {
String auth = username + ":" + password
httpRequest.addHeader('Authorization', 'Basic ' + auth.bytes.encodeBase64().toString())
}
})
post( query : pentahoQuery ) { resp, rd ->
// have your own implementation here
}
}
private Map buildQuery(ReportParam reportParam){
Map query = new HashMap()
// this 5 parameter is a must
query.put("output-target", reportParam.getOutputType())
query.put("renderMode", reportParam.getRenderMode())
query.put("solution", reportParam.getSolution())
query.put("path", reportParam.getPath())
query.put("name", reportParam.getName())
// this is additional parameter if needed in the report
if(reportParam.filterCriteria.size() > 0){
query.putAll(reportParam.filterCriteria)
}
return query
}
Note: – need to install plugins.rest=0.6
– ReportParam is my own class that i used to keep report parameter