Downloads a file from the repository to the current directory in the local environment.

If the content type of the response is application/JSON, then an error with details is displayed on the server. Otherwise, the content of the file is streamed through the response.

Note: The entire path to the file must be encoded, for example, changing / to %2F and spaces to %20. This API can be used to download files up to 1GB in a single request.

For example, change this path to an .HTML file in the apr directory:

apr/2020-03-04 23_07_20/2020-03-04 23_07_20.html

to this:


This REST API is version

Required Roles

Service Administrator

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

REST Resource

GET /interop/rest/{api_version}/applicationsnapshots/{applicationSnapshotName}/contents


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.


The following table summarizes the GET request parameters.

Table 9-22 Parameters

Name Description Type Required Default

Application snapshot name or file name to download (for example, "Artifact Snapshot" or s112.csv).

The entire applicationSnapshotName must be encoded before sending the request.

To download a particular file, provide the path to that file as the value of applicationSnapshotName. For example, to download a Data Management file called s112.csv in the inbox, refer to the file as "inbox\s112.csv" in the path parameter.

To download the Activity Reports or access log, use the fully qualified file name as shown in the output of List Files.

For example, to download a specific file from the apr directory, use the following format: pr%2F2020-03-04%0A23_07_20%2F2020-03-04%0A23_07_20.html apr%2F%0A2020-03-04%2023_07_20%2F%0Aactivityreport.json.

Path Yes None
api_version Specific API version Path Yes None

Example of Request


Table 9-23 Parameters

Name Description
Details In case of errors, details are published with the error string
Status See Migration Status Codes
Links Detailed information about the link
Href Links to API call
Action The HTTP call type
Rel Possibly value: self
Data Parameters as key value pairs passed in the request


Supported Media Types: application/json or application/octet-stream

Example of Response Body

The following shows an example of the response body in JSON format in case there is an error during download.

    "details": "Invalid file :",

Download Sample Code

Example 9-14 Java Sample –

Prerequisites: json.jar

Common Functions: See Common Helper Functions for Java.

public class DownloadFile600 {

	private String serverUrl; // PBCS server URL
	private String apiVersion = "";
	private String userName; // Server Username
	private String password; // Server Password
	private static String fileName; // file to be downloaded.

	public DownloadFile600(String userName, String password, String serverUrl, String apiVersion) {
		this.serverUrl = serverUrl;
		this.apiVersion = apiVersion;
		this.userName = userName;
		this.password = password;

	public void downloadFile(String fileName) throws Exception {
		HttpURLConnection connection = null;
		InputStream inputStream = null;
		FileOutputStream outputStream = null;

		try {
			fileName = fileName.replaceAll("/", "\\\\");
			URL url = new URL(String.format("%s/interop/rest/%s/applicationsnapshots/%s/contents", serverUrl,
					apiVersion, URLEncoder.encode(fileName, "UTF-8")));

			System.out.println("DOWNLOAD URL: " + url);
			connection = (HttpURLConnection) url.openConnection();
					"Basic " + new sun.misc.BASE64Encoder().encode((userName + ":" + password).getBytes()));
			int status = connection.getResponseCode();
			if (status == 200) {
				if (connection.getContentType() != null && connection.getContentType().equals("application/json")) {
					JSONObject json = new JSONObject(getStringFromInputStream(connection.getInputStream()));
					System.out.println("Error downloading file : " + json.getString("details"));
				} else {
					inputStream = connection.getInputStream();
					outputStream = downloadContent(connection, inputStream);
			} else {
				throw new Exception("Http status code: " + status);
		} finally {
			if (connection != null)
			if (outputStream != null)
			if (inputStream != null)

	private FileOutputStream downloadContent(HttpURLConnection connection, InputStream inputStream)
			throws FileNotFoundException, IOException {
		FileOutputStream outputStream;
		String downloadedFileName = fileName;
		if (fileName.lastIndexOf("/") != -1) {
			downloadedFileName = fileName.substring(fileName.lastIndexOf("/") + 1);

		String ext = ".zip";
		if (connection.getHeaderField("fileExtension") != null) {
			ext = "." + connection.getHeaderField("fileExtension");
		if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0)
			ext = fileName.substring(fileName.lastIndexOf(".") + 1);

		outputStream = new FileOutputStream(new File(downloadedFileName + ext));
		int bytesRead = -1;
		byte[] buffer = new byte[5 * 1024 * 1024];
		while ((bytesRead = != -1)
			outputStream.write(buffer, 0, bytesRead);
		System.out.println("File download completed.");
		return outputStream;