Import Template for Profitability and Cost Management

Imports a template zip file as an application from the inbox.

Required Roles

Service Administrator, Power User

REST Resource

POST /epm/rest/{api_version}/applications/{application}/jobs/templateImportJob

Note:

Before using the REST resources, you must understand how to access the REST resources and other important concepts. See Implementation Best Practices for EPM Cloud REST APIs. Using this REST API requires prerequisites. See Prerequisites.

Request

Supported Media Types: application/json

The following table summarizes the client request.

Table 24-25 Parameters

Name Description Type Required Default
api_version Version of the API you are developing with Path Yes None
application Name of the application Path Yes None
description User comment for the application Payload Yes None
fileName Name of the template zip file to be imported from the inbox folder Payload Yes None
isApplicationOverwrite Whether to override an application if one already exists with same name. Values are true or false. Payload Yes None

Example URL and Payload

https://<BASE-URL>/epm/rest/v1/applications/Ex3F3/jobs/templateImportJob

{"description":"description","fileName":" testFile12345.zip","isApplicationOverwrite":"true"}

Response

Supported Media Types: application/json

Table 24-26 Parameters

Name Description
details Task ID, such as TD_ae61e427d9ab4d6f99e3b87378fa1c94
status See Migration Status Codes
statusMessage Message about the status, such as In Progress
type Profitability
data Parameters as key value pairs
links Detailed information about the link
href Links to API call
action The HTTP call type
rel Relationship type
data Parameters as key value pairs passed in the request

Example of Response Body

The following shows an example of the response body in JSON format.

{
   "type":"Profitability",
   "status":-1,
   "statusMessage":"In Progress",
   "details":"BksML30_ImportTemplate_D20220511T114059_d3b",
   "links":[
      {
         "href":"http:// ://<BASE-URL>/epm/rest/v1/applications/jobs/ChecktaskStatusJob/BksML30_ImportTemplate_D20220511T114059_d3b",
         "action":"GET",
         "rel":"Job Status"
      }
   ]
}

Java Sample – ImportTemplate.java for Profitability and Cost Management

Prerequisites: json.jar

Common Functions: See Profitability and Cost Management Common Helper Functions for Java

    public void importTemplate() throws Exception {
        
        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", "HPCM_BksML12_20160128_200053.zip");
        json.put("isApplicationOverwrite", true);
        
        String urlString = "%s/epm/rest/%s/applications/%s/jobs/templateImportJob";
        executeJob(urlString, "POST", json.toString());
        
    }  

cURL Sample – ImportTemplate.sh for Profitability and Cost Management

Common Functions: See Profitability and Cost Management Common Helper Functions for cURL.

funcImportTemplate() {
	description="Import Template through Curl Sample"
	instance="PROFITABILITY_WEB_APP"
	essAppServer="EssbaseCluster-1"
	sharedServicesProject="EssbaseCluster-1"
	applicationType="Management Ledger"
	fileName="PCM_BksML12_20160413_042937.zip"
	isApplicationOverwrite="true"
	param="{\"description\":\"$description\",\"instanceName\":\"$instance\",\"essApplicationServer\":\"$essAppServer\",\"sharedServicesProject\":\"$sharedServicesProject\",\"applicationType\":\"$applicationType\",\"fileName\":\"$fileName\",\"isApplicationOverwrite\":\"$isApplicationOverwrite\"}"
	url=$SERVER_URL/epm/rest/$API_VERSION/applications/$APP_NAME/jobs/templateImportJob
	funcExecuteRequest "POST" $url "$param" "application/json"

	output=`cat response.txt`
	status=`echo $output | jq '.status'`
    if [ $status == -1 ]; then
        echo "Started importing successfully"
		funcGetStatus "GET"
    else
        error=`echo $output | jq '.details'`
        echo "Error occurred. " $error
    fi
	funcRemoveTempFiles "respHeader.txt" "response.txt"
}

Groovy Sample – ImportTemplate.groovy for Profitability and Cost Management

Prerequisites: json.jar

Common unctions: 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());

}