After an uploaded Structured Data File has been processed successfully, download
the resulting ZIP
file from the provided resource location using
media.download
.
Here's how to retrieve the file location and download the ZIP
file:
# Import the object used for media download. from googleapiclient import http as googleHttp import io # Provide the name of the successfully completed sdfuploadtask operation. operation_name = operation-name # Provide the path for the output file. output_path = output-path # Retrieve the completed operation. operation = service.sdfuploadtasks().operations().get(operation_name).execute() # Retrieve the file location from the operation. file_location = operation["response"]["resourceName"] # Configure the media.download request. download_request = service.media().download_media(resourceName=file_location) # Create output stream for downloaded file. out_stream = io.FileIO(output_path, mode='wb') # Build downloader object. downloader = googleHttp.MediaIoBaseDownload(out_stream, download_request) # Download file in chunks until finished. download_finished = False while download_finished is False: _, download_finished = downloader.next_chunk() print(f'File downloaded at {output_path}.')
Extract files
Decompress the downloaded ZIP
file to extract the results of your SDF upload.
One or both of the following possible result files may be present, with
{EntityName}
being the type of resource, such as LineItems
:
SDF-{EntityName}-Updated-ResultFile.csv
, which lists the resources that have been successfully created or updatedSDF-{EntityName}-Failed-ResultFile.csv
, which lists the resources that have failed to be updated or created, along with an error message.