Tạo yêu cầu sdfdownloadtasks.create
để tạo một tác vụ tải xuống tạo ra Tệp dữ liệu có cấu trúc (SDF).
Xác định SDF bằng các trường sau trong yêu cầu:
partnerId
hoặcadvertiserId
: Các trường loại trừ lẫn nhau xác định tài nguyên mẹ (đối tác hoặc nhà quảng cáo) cho các tài nguyên điền sẵn vào SDF.version
: Phiên bản SDF cần sử dụng, nếu khác với phiên bản mặc định được đặt ở cấp đối tác hoặc nhà quảng cáo.parentEntityFilter
,idFilter
hoặcinventorySourceFilter
: Các trường loại trừ lẫn nhau gán bộ lọc dùng để chỉ định các loại tệp và tài nguyên cần đưa vào.
Sử dụng đoạn mã này để tạo tác vụ tải xuống cho Đơn đặt hàng quảng cáo và Tệp dữ liệu có cấu trúc của mục hàng trong nhà quảng cáo đã cho và trong phạm vi của mã chiến dịch đã cung cấp:
# 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.')