Tryb wsadowy

Możesz użyć od custombatch do insert, get lub delete do jednego produktu w pojedynczym wywołaniu interfejsu API.

Aby wywołać niestandardowe interfejsy API wsadowego, użyj tego adresu URL żądania:

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

Treść żądania zawiera określone parametry: batchId, merchantID, i method.

productId używaj tylko wtedy, gdy wykonujesz pobieranie lub usuwanie. productId nie jest wymagany w przypadku wywołania interfejsu API insert dla custombatch.

custombatch:insert

Ten URL żądania jest używany do products.custombatch method=insert

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

Aby wstawić 2 nowe produkty, określ batchId dla każdego produktu, atrybut merchantId sprzedawcy autoryzowanego do wywołania interfejsu API oraz metoda insert

W poniższym przykładzie wartości batchId to 1111 i 1112 i unikalne identyfikatory każdego produktu. merchantId: 1234567 to sprzedawca autoryzowany do wywoływania interfejsu API, a metoda to get, delete lub insert.

insert tworzy nowy produkt. Czy atrybuty mają przypisane wartości channel, contentLanguage, offerId i feedLabel w przypadku danej wartości usługi, ta metoda aktualizuje wpis i zastępuje wszystkie dane z poprzedniego interfejsu API wzywa dany produkt.

Oto przykładowy tekst JSON do insert przesyłania 2 koszulek do Merchant Center bazy danych za pomocą pojedynczego wywołania interfejsu 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"
       
]
     
}
   
}
 
]
}

Udane wywołanie interfejsu API zwraca kod HTTP 200 i odpowiedź JSON, która obejmuje wstawione produkty. Format zwracanego kodu JSON jest podobny do tego:

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

Ten URL żądania wywołuje metodę products.custombatch z method=get:

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

Aby pobrać produkt, określ atrybut batchId, który jest dla niego unikalny dla wywołania interfejsu API, merchantId sprzedawcy autoryzowany do Wywołanie interfejsu API, metoda get i productId pobieranego produktu.

Poniżej znajdziesz przykładową treść żądania JSON do pobrania 2 produktów wstawiono przy użyciu poprzedniego przykładu custombatch:insert określonego według ich wartości productId. Identyfikator batchId jest unikalny dla każdego elementu na liście:

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

To wywołanie zwraca kod HTTP 200 i tę treść odpowiedzi:

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

Ten URL żądania jest używany do utworzenia właściwości products.custombatch z parametrem method=delete:

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

Aby usunąć produkt, określ batchId, który jest unikalny dla produktu w ramach tego wywołania interfejsu API, merchantId sprzedawcy autoryzowanego do wykonaj to wywołanie interfejsu API, metodę delete i productId produktu zostaną usunięte.

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

To wywołanie zwraca kod HTTP 200 i wartości batchId usuniętych elementy:

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