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

Prerequisites: json.jar

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

def updateDimensions() {
        
        JSONObject json = new JSONObject();
        json.put("dataFileName", "Accounts.txt");
        
        String urlString = serverUrl + "/epm/rest/"+ apiVersion + "/fileApplications/"+ appName + "/updateDimension";
        def url;
        
        try {
                url = new URL(urlString)
        } catch (MalformedURLException e) {
                println "Malformed URL. Please pass valid URL"
                System.exit(0);
        }
        
        String response = executeRequest(url, "POST", json.toString(), "application/json");
        JSONObject jsonObj = new JSONObject(response);
        int resStatus = jsonObj.getInt("status");
        
        if(resStatus == 0) {
            println "Dimensions updated successfully"
        } else {
            println "Dimensions update failed"
        } 
    }