How to create the custom report using API instead of SQL query?

We are planning to fetch the data using API instead of SQL query do you have any examples.

Hi @ibrahim.k_Ibrahim, I’ve grabbed this directly from the docs here. This shows an example in [any] plugin type utilizing a REST call:


The morpheus-plugin-api library comes with a utility for facilitating quick and easy API calls to external integrations. This is called teh HttpApiClient and replaces the use of the RestApiUtil.

The developer is, of course, able to utilize any HTTP or SDK/API client they choose within the java ecosystem if so desired. However, this client provides some common functions such as SSL Validation, Throttling, Keep-Alive, Etc. and is based on the Apache HTTP Client.

TIP Reuse the same client instance when dealing with periodic refresh methods related to caching for best performance. Be mindful that throttling might be necessary to slow down the calls to the service.


Below is an example API Call taken from the Infoblox plugin.

import com.morpheusdata.core.util.HttpApiClient

HttpApiClient infobloxClient = new HttpApiClient()
try {
    def results = infobloxClient.callJsonApi(serviceUrl, apiPath, poolServer.serviceUsername, poolServer.servicePassword, new HttpApiClient.RequestOptions(headers:['Content-Type':'application/json'],
                                                                                                                    queryParams:pageQuery, ignoreSSL: poolServer.ignoreSsl), 'GET')
} catch(e) {
    log.error("verifyPoolServer error: ${e}", e)
} finally {
return rtn

There are several methods to call the api and automatically handle certain payload formats such as callJsonApi, callXmlApi, or plain callApi.

Options can be passed relating to the request via the HttpApiClient.RequestOptions object. Please refer to the java api doc for available options.

TIP Remember to always shutdown the client after it is used to clean up the connection manager in a try{} finally{} type block

Thanks for the details. I am planning to retrieve the few information using API and show it in the custom report. In that document I didn’t see any details for renderer maping.

Below is the example code:

import groovy.json.JsonSlurper
import java.util.Base64.Encoder

// Create a trust manager that does not validate certificate chains like the default

TrustManager trustAllCerts = new TrustManager{
new X509TrustManager() {

        public[] getAcceptedIssuers()
            return null;
        public void checkClientTrusted([] certs, String authType)
            //No need to implement.
        public void checkServerTrusted([] certs, String authType)
            //No need to implement.


// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance(“SSL”);
sc.init(null, trustAllCerts, new;
catch (Exception e)

def message = ‘{“username”:“”, “password”:“cityslicka”}’
def post = new URL(“”).openConnection();
post.setRequestProperty(“Content-Type”, “application/json”)
def postRC = post.getResponseCode()
def results = post.getInputStream().getText()
def slurper = new groovy.json.JsonSlurper()
def json = slurper.parseText(results)

It will return the token I wants to store and return the value in renderer.hbs