Download the SDF

Once your operation has finished successfully and you’ve extracted the resource name from the completed operation response, you are ready to download the zip file containing your generated SDFs using the media.download method.

Here's an example of how to use a client library to download the resulting file:

Java

// Extract download file resource name to use in download request
String downloadResourceName = operationResponse.getResponse()
    .get("resourceName").toString();

// Configure the Media.download request
Media.Download downloadRequest =
   service
       .media()
       .download(downloadResourceName);

// Create output stream for downloaded file
FileOutputStream outStream =
   new FileOutputStream(output-file);

// Download file
downloadRequest.executeMediaAndDownloadTo(outStream);

System.out.printf("File downloaded to %s\n", outputFile);

Python

# Extract download file resource name to use in download request
resourceName = operation["response"]["resourceName"]

# Configure the Media.download request
downloadRequest = service.media().download_media(resourceName=resourceName)

# Create output stream for downloaded file
outStream = io.FileIO(output-file, mode='wb')

# Make downloader object
downloader = googleHttp.MediaIoBaseDownload(outStream, downloadRequest)

# Download media file in chunks until finished
download_finished = False
while download_finished is False:
  _, download_finished = downloader.next_chunk()

print("File downloaded to %s" % output-file)

PHP

// Get client and set defer so it doesn't immediately return.
$client = $this->service->getClient();
$client->setDefer(true);

// Build media download request.
$request = $this->service->media->download(
    $operation->getResponse()['resourceName'],
    array('alt' => 'media')
);

// Call the API, getting the generated SDF.
$response = $client->execute($request);
$responseBody = $response->getBody();

// Writes the downloaded file. If the file already exists, it is
// overwritten.
file_put_contents(output-file, $responseBody);
$client->setDefer(false);

printf('File saved to: %s\n', output-file);

Once your file is downloaded and unzipped, your generated structured data files will be available to you. The generated files will have generic names identifying the SDF file type (example: SDF-LineItems.csv).

Skipped files

If data for a requested resource cannot be included in the corresponding structured data file, the zip file downloaded might include a "Skipped" file (example: SDF-LineItems-Skipped.csv). This file will have a two-column structure, the first containing the IDs of the resources that couldn’t be included and the second containing the reason for their exclusion.

Resources may be skipped for many reasons, including being in an unsupported state or of an unsupported type. Avoid having resources skipped by using the most recent version of SDF.