Delete Files (v11.1.2.3.600)

Use the Delete Files (v11.1.2.3.600) REST API to delete a file from the Planning repository.

This topic describes the original version of this REST API. You can also use the simplified v2 version of the REST API. The v2 version contains all parameters in the payload and does not require URL encoding while calling the REST APIs. This makes the v2 API easier to use. The v2 version is backwards compatible.

Specify the filename with path separators in percent-encoding format, for example, using %5C as the encoded value for \ (file separator). For a file named inbox/file1.csv, pass it as inbox%5Cfile1.csv. If you are calling the cURL command to trigger the REST API, you can use a backslash \ for the path separator without URL encoding. See About EPM Automate in Working with EPM Automate for Oracle Enterprise Performance Management Cloud.

This REST API is version 11.1.2.3.600.

Required Roles

Service Administrator

Power User assigned to the Migration Administrator Profitability and Cost Management application role

REST Resource

DELETE /interop/rest/{api_version}/applicationsnapshots/{applicationSnapshotName

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 request parameters.

Table 9-27 Parameters

Name Description Type Required Default
api_version Specific API version Path Yes None
applicationSnapshotName Application snapshot name that needs to be deleted Path Yes None

Response

Supported Media Types: application/json

Table 9-28 Parameters

Parameters Description
Details Published if there is an error with the error string
Status See Migration Status Codes
Links Detailed information about the link
Href Links to the API call
Action The HTTP call type
Rel Possible value: self
Data Parameters as key value pair passed in the request

Example of Response Body

{
	"status":0,
	"links":[{
		"data":null,
		"action":"DELETE",
		"rel":"self",
		"href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/11.1.2.3.600/applicationsnapshots/ss2"
	}],
	"details":null
}

Delete Files Sample Code

Example 9-18 Java Sample – deleteFile.java

Prerequisites: json.jar

Common Functions: See Common Helper Functions for Java

//
// BEGIN - Delete a file in PBCS
//
public void deleteFile(String fileName) throws Exception {
	String urlString = String.format("%s/interop/rest/%s/applicationsnapshots/%s", serverUrl, apiVersion, fileName);
	String response = executeRequest(urlString, "DELETE", null);
	JSONObject json = new JSONObject(response);
	int resStatus = json.getInt("status");
	if (resStatus == 0)
		System.out.println("File deleted successfully");
	else
		System.out.println("Error deleting file : " + json.getString("details"));
}
//
// END - Delete a file in PBCS
//

Example 9-19 cURL Sample – DeleteFile.sh

Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq)

Common Functions: See Common Helper Functions for cURL

funcDeleteFile() {
	encodedFileName=$(echo $1 | sed -f urlencode.sed)
	url=$SERVER_URL/interop/rest/$API_VERSION/applicationsnapshots/$encodedFileName
	funcExecuteRequest "DELETE" $url

	output=`cat response.txt`
	status=`echo $output | jq '.status'`
    if [ $status == 0 ]; then
        echo "Deleted successfully"
    else
        error=`echo $output | jq '.details'`
        echo "Error occurred. " $error
    fi
	funcRemoveTempFiles "respHeader.txt" "response.txt"
}

Example 9-20 Groovy Sample – DeleteFile.groovy

Prerequisites: json.jar

Common Functions: CSS Common Helper Functions for Groovy

def deleteFile(filename) {
	def url;
	try {
		String encodedFileName = URLEncoder.encode(filename, "UTF-8");
		url = new URL(serverUrl + "/interop/rest/" + apiVersion + "/applicationsnapshots/" + encodedFileName)
	} catch (MalformedURLException e) {
		println "Malformed URL. Please pass valid URL"
		System.exit(0);
	}
	response = executeRequest(url, "DELETE", null);
	def object = new JsonSlurper().parseText(response)
	def status = object.status
	if (status == 0 )
		println "File deleted successfully"
	else {
		println "Error occurred while deleting file"
		if (object.details != null)
			println "Error details: " + object.details
	}
}
Common Functions