คุณสามารถใช้ custombatch
เพื่อ insert
, get
หรือ delete
ผลิตภัณฑ์หลายรายการพร้อมกันในการเรียก API เพียงครั้งเดียว
ใช้ URL คำขอต่อไปนี้เพื่อเรียก API แบบกลุ่มที่กำหนดเอง
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
เนื้อหาของคำขอมีพารามิเตอร์ที่เฉพาะเจาะจง: batchId
, merchantID
และ method
ใช้ productId
เฉพาะในกรณีที่ดำเนินการเรียกหรือลบเท่านั้น ไม่จำเป็นต้องใช้ productId
ในการเรียก API แบบแทรกสำหรับ custombatch
custombatch:แทรก
มีการใช้ 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 สำหรับเสื้อยืด 2 ตัวของ insert
ในฐานข้อมูล 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:ลบ
คุณใช้ 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
}
]
}