สร้างงานการดาวน์โหลด

ส่งคำขอ sdfdownloadtasks.create เพื่อสร้าง งานดาวน์โหลดที่สร้างไฟล์ Structured Data (SDF)

กำหนด SDF โดยใช้ช่องต่อไปนี้ของคำขอ

  • partnerId หรือ advertiserId: ฟิลด์ที่แยกกัน ซึ่งกำหนดทรัพยากรหลัก (ทั้งพาร์ทเนอร์หรือผู้ลงโฆษณา) สำหรับ ทรัพยากรที่สร้าง SDF
  • version: เวอร์ชัน SDF ที่จะใช้ หากแตกต่างจากค่าเริ่มต้นที่ตั้งไว้ที่ระดับพาร์ทเนอร์หรือผู้ลงโฆษณา
  • parentEntityFilter, idFilter หรือ inventorySourceFilter: ฟิลด์ที่แยกกันซึ่งกำหนด ตัวกรองที่ใช้เพื่อระบุประเภทไฟล์และทรัพยากรที่จะรวม

ใช้ข้อมูลโค้ดนี้เพื่อสร้างงานดาวน์โหลดสำหรับไฟล์ข้อมูลที่มีโครงสร้างของใบสั่งซื้อการใส่โฆษณาและรายการโฆษณาภายใต้ผู้ลงโฆษณาที่ระบุและภายในขอบเขตของรหัสแคมเปญที่ระบุ

# 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.')