Groovy Sample – ExportTemplate.groovy for Profitability and Cost Management

Prerequisites: json.jar

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

def exportTemplate() {
        String fileName = appName + "_Template_Export_File";
        
        JSONObject json = new JSONObject();
        json.put("fileName", fileName);
        
        String urlString = serverUrl + "/epm/rest/"+ apiVersion + "/applications/" + appName + "/jobs/templateExportJob";
                
        def url;    
        
        try {
                url = new URL(urlString)
        } catch (MalformedURLException e) {
                println "Malformed URL. Please pass valid URL"
                System.exit(0);
        }        
        executeJob(url, "POST", json.toString());        
}