Modalità batch

Puoi utilizzare custombatch per insert, get o delete più prodotti contemporaneamente in una singola chiamata API.

Utilizza il seguente URL di richiesta per effettuare una chiamata alle API batch personalizzate:

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

Il corpo della richiesta contiene parametri specifici: batchId, merchantID, e un method.

Usa productId solo se stai eseguendo un comando get o delete. productId non è obbligatorio in una chiamata API Insert per custombatch.

custombatch:insert

Il seguente URL di richiesta viene usato per creare products.custombatch method=insert

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

Per inserire i due nuovi prodotti, specifica il batchId per ogni prodotto, merchantId del commerciante autorizzato a effettuare la chiamata API e il metodo insert.

Nell'esempio seguente, i valori batchId sono 1111 e 1112 e si tratta di identificatori univoci per ciascun prodotto. merchantId: 1234567 è il commerciante autorizzato a effettuare la chiamata API e il metodo è get, delete o insert.

Un insert crea un nuovo prodotto. Se esistono valori per gli attributi channel, contentLanguage, offerId e feedLabel per un determinato questo prodotto aggiorna la voce e sostituisce tutti i dati dell'API precedente per il prodotto.

Ecco un esempio di corpo in formato JSON per insert due t-shirt in Merchant Center utilizzando una singola chiamata 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"
       
]
     
}
   
}
 
]
}

Una chiamata API riuscita restituisce un codice HTTP 200 e una risposta JSON che include i prodotti che sono stati inseriti. Il formato del JSON restituito è simile al seguente:

{
 
"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

Il seguente URL di richiesta effettua una chiamata products.custombatch con method=get:

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

Per ottenere un prodotto, specifica il batchId univoco del prodotto per la chiamata API, il merchantId del commerciante autorizzato a effettuare Chiamata API, il metodo get e productId del prodotto recuperato.

Di seguito è riportato un corpo di richiesta JSON di esempio per il recupero dei due prodotti inserita utilizzando l'esempio precedente di custombatch:insert, specificato in base ai relativi valori productId. batchId è univoco per ogni elemento nell'elenco:

{
 
"entries": [
   
{
     
"batchId": 1113,
     
"merchantId": 1234567,
     
"method": "get",
     
"productId": "online:en:US:1111111111"
   
},
   
{
     
"batchId": 1114,
     
"merchantId": 1234567,
     
"method": "get",
     
"productId": "online:en:US:2222222222"
   
}
 
]
}

Questa chiamata restituisce un codice HTTP 200 e il seguente corpo della risposta:

{
 
"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

Il seguente URL di richiesta viene usato per creare products.custombatch con method=delete:

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

Per eliminare un prodotto, specifica il batchId univoco del prodotto in questa chiamata API, il numero merchantId del commerciante autorizzato a esegui questa chiamata API, il metodo delete e productId del prodotto in fase di eliminazione.

{
 
"entries": [
   
{
     
"batchId": 1115,
     
"merchantId": 1234567,
     
"method": "delete",
     
"productId": "online:en:US:1111111111"
   
},
   
{
     
"batchId": 1116,
     
"merchantId": 1234567,
     
"method": "delete",
     
"productId": "online:en:US:2222222222"
   
}
 
]
}

Questa chiamata restituisce un codice HTTP 200 e i valori batchId dell'elemento eliminato articoli:

{
 
"kind": "content#productsCustomBatchResponse",
 
"entries": [
 
{
   
"kind": "content#productsCustomBatchResponseEntry",
   
"batchId": 1115
 
},
 
{
   
"kind": "content#productsCustomBatchResponseEntry",
   
"batchId": 1116
 
}
 
]
}