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