建立下載工作

提出 sdfdownloadtasks.create 要求,建立產生結構化資料檔案 (SDF) 的下載工作。

使用要求的下列欄位定義 SDF:

使用這段程式碼片段,為指定廣告主建立廣告訂單和委刊項結構化資料檔案的下載工作,並在提供的廣告活動 ID 範圍內執行:

# Provide the ID of the parent advertiser of the resources to retrieve.
advertiser_id = advertiser-id

# Provide the Structured Data Files version to download.
sdf_version = sdf-version

# Provide the IDs of the parent campaigns of the resources to retrieve.
campaign_ids = [campaign-id, ...]

# Create the request body.
body = {
  'version': sdf_version,
  'advertiserId': advertiser_id,
  'parentEntityFilter': {
    'fileType': ["FILE_TYPE_INSERTION_ORDER","FILE_TYPE_LINE_ITEM"],
    'filterType': "FILTER_TYPE_CAMPAIGN_ID",
    'filterIds': campaign_ids
  }
}

# Create the operation.
operation = service.sdfdownloadtasks().create(body=body).execute()

# Print resulting operation name.
print(f'Operation {operation["name"]} was created.')