אפשר להשתמש ב-custombatch
כדי insert
, ב-get
או ב-delete
מספר מוצרים בו-זמנית בקריאה אחת ל-API.
כדי לבצע קריאה לממשקי ה-API באצווה בהתאמה אישית, צריך להשתמש בכתובת ה-URL הבאה:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
גוף הבקשה מכיל פרמטרים ספציפיים: batchId
, merchantID
ו-method
.
יש להשתמש ב-productId
רק אם מבצעים get או Delete. לא צריך את ה-productId
בקריאה ל-Insert API ל-custombatch
.
custombatch:insert
כתובת ה-URL הבאה של הבקשה משמשת ליצירת products.custombatch method=insert
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
כדי להוסיף את שני המוצרים החדשים, צריך לציין batchId
לכל מוצר, את המאפיין merchantId
של המוכר שמורשה לבצע את הקריאה ל-API, ואת השיטה insert
.
בדוגמה הבאה, הערכים של batchId
הם 1111
ו-1112
בהתאמה, והם מזהים ייחודיים של כל מוצר. merchantId:
1234567
הוא המוכר שמורשה לבצע את הקריאה ל-API. השיטה היא get
, delete
או insert
.
insert
יוצר מוצר חדש. אם קיימים ערכים למאפיינים channel
, contentLanguage
, offerId
ו-feedLabel
בשביל מוצר נתון, ה-method הזה מעדכנת את הרשומה ומחליפה את כל הנתונים מקריאות ה-API הקודמות של המוצר.
לפניכם גוף JSON לדוגמה ל-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 לאחזור שני המוצרים שנוספו באמצעות הדוגמה הקודמת של 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
}
]
}