Groovy Sample – ImportTemplate.groovy for Oracle Profitability and Cost Management Cloud

Prerequisites: json.jar

Common functions: See Appendix C: Common Helper Functions for Groovy.

def importTemplate() {
                
        JSONObject json = new JSONObject();
        json.put("description", "Import Template");
        json.put("instanceName", "PROFITABILITY_WEB_APP");
        json.put("essApplicationServer", "EssbaseCluster-1");
        json.put("sharedServicesProject", "EssbaseCluster-1");
        json.put("applicationType", "Management Ledger");
        json.put("fileName", "BksML12_Template.zip");
        json.put("isApplicationOverwrite", true);
        
        def url;
        def response;
        
        try {
                 url = new URL(serverUrl + "/epm/rest/" + apiVersion + "/applications/" + appName + "/jobs/templateImportJob")
        } catch (MalformedURLException e) {
                 println "Malformed URL. Please pass valid URL"
                 System.exit(0);
        }
        println "URL : " + url
        println "Payload : " + json.toString()
        executeJob(url, "POST", json.toString());

}