बैच मोड

एक एपीआई कॉल में एक बार में insert, get या delete के कई प्रॉडक्ट के लिए custombatch का इस्तेमाल किया जा सकता है.

कस्टम बैच एपीआई को कॉल करने के लिए, इस अनुरोध यूआरएल का इस्तेमाल करें:

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

अनुरोध के मुख्य हिस्से में ये पैरामीटर शामिल हैं: batchId, merchantID, और एक method.

productId का इस्तेमाल सिर्फ़ तब करें, जब get या delete को एक्ज़ीक्यूट किया जा रहा हो. custombatch के लिए, Insert API कॉल के लिए productId की ज़रूरत नहीं है.

कस्टमबैच:डालें

इस अनुरोध के यूआरएल का इस्तेमाल, 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"
    ]
   }
  }
 ]
}

कस्टमबैच:get

नीचे दिया गया अनुरोध यूआरएल, method=get के साथ products.custombatch कॉल करता है:

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

प्रॉडक्ट पाने के लिए, उस batchId की जानकारी दें जो एपीआई कॉल के लिए प्रॉडक्ट का यूनीक है. साथ ही, एपीआई कॉल करने के लिए, कारोबारी या कंपनी के merchantId, तरीके, get, और वापस लाए जा रहे प्रॉडक्ट के productId की जानकारी दें.

नीचे custombatch:insert के पिछले उदाहरण का इस्तेमाल करके, शामिल किए गए दो प्रॉडक्ट को वापस पाने के लिए, JSON अनुरोध का मुख्य हिस्सा दिया गया है. इस कोड को 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"
    ]
   }
  }
 ]
}

कस्टमबैच:मिटाएं

इस अनुरोध यूआरएल का इस्तेमाल 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
  }
 ]
}