Groovy Sample – GetRestAPIVersionsInfo.groovy for Profitability and Cost Management

Prerequisites: json.jar

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

def getRestAPIVersionsInfo() {
                 def url;
                 def response;
	try {
                           url = new URL(serverUrl + "/epm/rest");
	} catch (MalformedURLException e) {
	         println "Malformed URL. Please pass valid URL"
	         System.exit(0);
	}
	response = executeRequest(url, "GET", null, "application/json");
	def object = new JsonSlurper().parseText(response)       
        
                 if(object != null) {
                      def items = object.items
                      println "Rest API Versions Info : " + items
	} else {
                      println "Error occurred while fetching rest api versions details"
	}
}