发出 sdfdownloadtasks.create 请求,以创建生成结构化数据文件 (SDF) 的下载任务。
使用请求的以下字段定义 SDF:
partnerId或advertiserId:互斥字段,用于为填充 SDF 的资源定义父资源(合作伙伴或广告客户)。version:要使用的 SDF 版本(如果与合作伙伴级或广告客户级设置的默认版本不同)。parentEntityFilter、idFilter或inventorySourceFilter:互斥字段,用于分配指定要包含的文件类型和资源的过滤条件。
使用此代码段可为指定广告客户下且在所提供广告系列 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.')