एक ही एपीआई कॉल में, एक साथ कई प्रॉडक्ट insert
, get
या delete
करने के लिए, custombatch
का इस्तेमाल किया जा सकता है.
कस्टम बैच एपीआई को कॉल करने के लिए, इस अनुरोध यूआरएल का इस्तेमाल करें:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
अनुरोध के मुख्य हिस्से में कुछ पैरामीटर शामिल होते हैं: batchId
, merchantID
, और method
.
सिर्फ़ get या delete कार्रवाई करते समय productId
का इस्तेमाल करें. productId
के लिए, इंसर्ट एपीआई कॉल में custombatch
की ज़रूरत नहीं होती.
custombatch:insert
नीचे दिए गए अनुरोध यूआरएल का इस्तेमाल, products.custombatch method=insert
के लिए किया जाता है
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
दो नए प्रॉडक्ट डालने के लिए, हर प्रॉडक्ट के लिए batchId
, एपीआई कॉल करने के लिए अधिकृत कारोबारी या कंपनी का merchantId
, और तरीका insert
डालें.
यहां दिए गए उदाहरण में, batchId
वैल्यू 1111
और 1112
हैं. ये हर प्रॉडक्ट के लिए यूनीक आइडेंटिफ़ायर हैं. merchantId:
1234567
वह कारोबारी या कंपनी है जिसे एपीआई कॉल करने की अनुमति मिली है. साथ ही, तरीका get
, delete
या insert
है.
insert
से नया प्रॉडक्ट बनता है. अगर किसी प्रॉडक्ट के लिए, एट्रिब्यूट channel
, contentLanguage
, offerId
, और feedLabel
की वैल्यू मौजूद हैं, तो यह तरीका एंट्री को अपडेट करता है. साथ ही, प्रॉडक्ट के लिए एपीआई के पिछले कॉल से मिले सभी डेटा को बदल देता है.
यहां एक एपीआई कॉल का इस्तेमाल करके, Merchant Center के डेटाबेस में दो टी-शर्ट insert
करने के लिए, JSON बॉडी का सैंपल दिया गया है:
{
"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"
]
}
}
]
}
एपीआई कॉल पूरा होने पर, 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
अनुरोध करने वाले इस यूआरएल से, products.custombatch
कॉल किया जाता है. इसमें method=get
शामिल है:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
किसी प्रॉडक्ट को पाने के लिए, एपीआई कॉल के लिए प्रॉडक्ट का यूनीक batchId
, एपीआई कॉल करने के लिए अधिकृत कारोबारी या कंपनी का merchantId
, तरीका 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
नीचे दिए गए अनुरोध यूआरएल का इस्तेमाल, products.custombatch
के साथ method=delete
करने के लिए किया जाता है:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
किसी प्रॉडक्ट को मिटाने के लिए, इस एपीआई कॉल में प्रॉडक्ट के लिए यूनीक batchId
, इस एपीआई कॉल को करने के लिए अधिकृत कारोबारी या कंपनी का merchantId
, तरीका 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
}
]
}