คุณสามารถใช้ custombatch เพื่อ insert, get หรือ delete ผลิตภัณฑ์หลายรายการพร้อมกันได้ในการเรียก API ครั้งเดียว

ใช้ URL ของคำขอต่อไปนี้เพื่อเรียก API แบบกลุ่มที่กำหนดเอง
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
เนื้อหาคำขอมีพารามิเตอร์ที่เฉพาะเจาะจง ได้แก่ batchId, merchantID และ method
ใช้ productId เฉพาะในกรณีที่คุณกำลังดำเนินการ get หรือ delete ไม่จำเป็นต้องระบุ productId
ในการเรียก API เพื่อแทรกสำหรับ custombatch
custombatch:insert
ใช้ URL ของคำขอต่อไปนี้เพื่อสร้าง products.custombatch method=insert
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
หากต้องการแทรกผลิตภัณฑ์ใหม่ 2 รายการ ให้ระบุ batchId สำหรับผลิตภัณฑ์แต่ละรายการ merchantId ของผู้ขายที่ได้รับอนุญาตให้ทำการเรียก API และเมธอด insert
ในตัวอย่างต่อไปนี้ ค่า batchId คือ 1111 และ 1112 ตามลำดับ และเป็นตัวระบุที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์แต่ละรายการ merchantId:
1234567 คือผู้ขายที่ได้รับอนุญาตให้ทำการเรียก API และเมธอดคือ get, delete หรือ insert
insert จะสร้างผลิตภัณฑ์ใหม่ หากมีค่าสำหรับแอตทริบิวต์
channel, contentLanguage, offerId และ feedLabel สำหรับผลิตภัณฑ์ที่ระบุ
 วิธีนี้จะอัปเดตรายการและแทนที่ข้อมูลทั้งหมดจากการเรียก API ก่อนหน้า
สำหรับผลิตภัณฑ์
ต่อไปนี้คือตัวอย่างเนื้อหา JSON เพื่อinsertเสื้อยืด 2 ตัวลงในฐานข้อมูล Merchant Center
 โดยใช้การเรียก API ครั้งเดียว
{
  "entries": [
    {
      "batchId": 1111,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "1111111111",
        "title": "Google Tee Black",
        "description": "The Black Google Tee is available in unisex sizing and
        features a retail fit.",
        "link": "http://my.site.com/blacktee/",
        "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
        "contentLanguage": "en",
        "targetCountry": "US",
        "feedLabel": "US",
        "channel": "online",
        "ageGroup": "adult",
        "availability": "in stock",
        "availabilityDate": "2019-01-25T13:00:00-08:00",
        "brand": "Google",
        "color": "black",
        "condition": "new",
        "gender": "male",
        "googleProductCategory": "1604",
        "gtin": "608802531656",
        "itemGroupId": "google_tee",
        "mpn": "608802531656",
        "price": {
          "value": "21.99",
          "currency": "USD"
        },
        "sizes": [
          "Large"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    },
    {
      "batchId": 1112,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "2222222222",
        "title": "Google Tee Green",
        "description": "100% cotton jersey fabric sets  this Google t-shirt above
        the crowd. Features the google logo across the chest. Unisex sizing.",
        "link": "http://my.site.com/greentee/",
        "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
        "contentLanguage": "en",
        "targetCountry": "US",
        "feedLabel": "US",
        "channel": "online",
        "ageGroup": "adult",
        "availability": "in stock",
        "availabilityDate": "2019-01-25T13:00:00-08:00",
        "brand": "Google",
        "color": "green",
        "condition": "new",
        "gender": "male",
        "googleProductCategory": "1604",
        "gtin": "608802531649",
        "itemGroupId": "google_tee",
        "mpn": "608802531649",
        "price": {
          "value": "21.99",
          "currency": "USD"
        },
        "sizes": [
          "Medium"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    }
  ]
}
การเรียก API ที่สำเร็จจะแสดงรหัส HTTP 200 และการตอบกลับ JSON ที่
มีผลิตภัณฑ์ที่แทรก รูปแบบของ JSON ที่ส่งคืน
จะคล้ายกับตัวอย่างต่อไปนี้
{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1111,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and
    features a retail fit.",
    "link": "http://my.site.com/blacktee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "black",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531656",
    "itemGroupId": "google_tee",
    "mpn": "608802531656",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Large"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1112,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "title": "Google Tee Green",
    "description": "100% cotton jersey fabric sets this Google t-shirt above
    the crowd. Features the google logo across the chest. Unisex sizing.",
    "link": "http://my.site.com/greentee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "green",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531649",
    "itemGroupId": "google_tee",
    "mpn": "608802531649",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Medium"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}
custombatch:get
URL คำขอต่อไปนี้จะเรียกใช้ products.custombatch โดยมี
method=get
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
หากต้องการรับผลิตภัณฑ์ ให้ระบุ batchId ที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์
สำหรับการเรียก API, merchantId ของผู้ขายที่ได้รับอนุญาตให้ทำการ
เรียก API, เมธอด get และ productId ของผลิตภัณฑ์ที่กำลังดึงข้อมูล
ต่อไปนี้คือตัวอย่างเนื้อหาของคำขอ JSON สำหรับการดึงข้อมูลผลิตภัณฑ์ 2 รายการที่แทรกโดยใช้ตัวอย่าง custombatch:insert ก่อนหน้า ซึ่งระบุโดยค่า productId batchId จะไม่ซ้ำกันสำหรับแต่ละรายการในลิสต์
{
  "entries": [
    {
      "batchId": 1113,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1114,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:2222222222"
    }
  ]
}
การเรียกนี้จะแสดงรหัส HTTP 200 และเนื้อหาการตอบกลับต่อไปนี้
{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1113,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and features a retail fit.",
    "link": "http://my.site.com/blacktee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "black",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531656",
    "itemGroupId": "google_tee",
    "mpn": "608802531656",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Large"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1114,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "title": "Google Tee Green",
    "description": "100% cotton jersey fabric sets this Google t-shirt above the crowd.
    Features the google logo across the chest. Unisex sizing.",
    "link": "http://my.site.com/greentee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "green",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531649",
    "itemGroupId": "google_tee",
    "mpn": "608802531649",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Medium"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}
custombatch:delete
ใช้ URL ของคำขอต่อไปนี้เพื่อสร้าง products.custombatch ด้วย
method=delete
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
หากต้องการลบผลิตภัณฑ์ ให้ระบุ batchId ที่ไม่ซ้ำกันสำหรับ
ผลิตภัณฑ์ในการเรียก API นี้ merchantId ของผู้ขายที่ได้รับอนุญาตให้
ทำการเรียก API นี้ เมธอด delete และ productId ของผลิตภัณฑ์
ที่จะลบ
{
  "entries": [
    {
      "batchId": 1115,
      "merchantId": 1234567,
      "method": "delete",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1116,
      "merchantId": 1234567,
      "method": "delete",
      "productId": "online:en:US:2222222222"
    }
  ]
}
การเรียกนี้จะแสดงรหัส HTTP 200 และค่า batchId ของรายการที่ถูกลบ
{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1115
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1116
  }
 ]
}