Download Report Files

The DCM/DFA Reporting and Trafficking API allows you to download report files, which are the result of running a Report Builder report. It also supports providing users direct access to a file via a link.

Depending on the type of download you'd like to perform, you'll use one of the following approaches:

The rest of this guide provides detailed instructions for performing these types of downloads via the Files resource.


In order to download a file, you'll need a few pieces of information:

  1. The ID of the report to which the file belongs. You can find this by creating a new report, or looking up an existing report.
  2. The ID of the file to download. You can find this by running the report from the previous step, or querying the list of existing files as in the example below:


File target = null;
FileList files;
String nextPageToken = null;

do {
  // Create and execute the files list request.
  files = reporting.reports().files().list(profileId, reportId).setPageToken(nextPageToken)

  for (File file : files.getItems()) {
    if (isTargetFile(file)) {
      target = file;

  // Update the next page token.
  nextPageToken = files.getNextPageToken();
} while (!files.getItems().isEmpty() && !Strings.isNullOrEmpty(nextPageToken));

Note that the status field of the file resource must be set to REPORT_AVAILABLE to be eligible to download.

Direct download

To perform a direct download, you make an authorized HTTP GET request to the Files service and include the query parameter alt=media. An example request may look like this:

Authorization: Bearer your_auth_token

Be aware that the response you receive will contain a redirect, so your application should ideally be configured to handle this automatically. If you prefer to handle this manually, you can find the redirect URL in the Location header of the response.

Most of the official Google client libraries provide convenience methods for initiating a direct download, as shown in the example below. If you prefer to initiate a download manually, a pre-constructed URL is provided in the apiUrl field of the file resource.


// Retrieve the file metadata.
File file = reporting.files().get(reportId, fileId).execute();

if ("REPORT_AVAILABLE".equals(file.getStatus())) {
  // Prepare a local file to download the report contents to. outFile = new, generateFileName(file));

  // Create a get request.
  Get getRequest = reporting.files().get(reportId, fileId);

  // Optional: adjust the chunk size used when downloading the file.
  // getRequest.getMediaHttpDownloader().setChunkSize(MediaHttpDownloader.MAXIMUM_CHUNK_SIZE);

  // Execute the get request and download the file.
  try (OutputStream stream = new FileOutputStream(outFile)) {

  System.out.printf("File %d downloaded to %s%n", file.getId(), outFile.getAbsolutePath());

Resumable downloads

When downloading large report files, it’s possible for the download to fail partway through. To make it easier to recover and resume a failed download, the file service supports partial download functionality.

Partial download involves requesting specific portions of a file, allowing you to break large downloads into smaller chunks. You can specify which portion of a file you want to download by including a byte range in the Range HTTP header of your request. For example:

Range: bytes=500-999

Partial download functionality is provided by many client libraries via a Media Download service. Refer to the client library documentation for details.

Download files in a browser

If you'd like to provide users with a way to download a file directly from their web browser, you can use the URL provided in the browserUrl field of the File resource. You can redirect a user to this URL, or offer it as a clickable link. In either case, the user will need to be logged into a Google account with access to DDM Reporting and have the correct permissions to access the specified file, in order to start the download.


File file = reporting.files().get(reportId, fileId).execute();
String browserUrl = file.getUrls().getBrowserUrl();

Send feedback about...

DoubleClick Campaign Manager
DoubleClick Campaign Manager