Anda dapat menggunakan custombatch
untuk insert
, get
, atau delete
beberapa produk sekaligus dalam satu panggilan API.
Gunakan URL permintaan berikut untuk melakukan panggilan ke API batch kustom:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
Isi permintaan berisi parameter tertentu: batchId
, merchantID
,
dan method
.
Hanya gunakan productId
jika Anda menjalankan perintah get atau delete. productId
tidak diperlukan pada panggilan API penyisipan untuk custombatch
.
custombatch:insert
URL permintaan berikut digunakan untuk membuat products.custombatch method=insert
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
Untuk menyisipkan dua produk baru, tentukan batchId
untuk setiap produk, merchantId
penjual yang diberi otorisasi untuk melakukan panggilan API, dan metode
insert
.
Pada contoh berikut, nilai batchId
masing-masing adalah 1111
dan 1112
, dan merupakan ID unik untuk setiap produk. merchantId:
1234567
adalah penjual yang diberi otorisasi untuk melakukan panggilan API, dan metodenya
adalah get
, delete
, atau insert
.
insert
membuat produk baru. Jika ada nilai untuk atribut
channel
, contentLanguage
, offerId
, dan feedLabel
untuk produk
tertentu, metode ini akan memperbarui entri dan mengganti semua data dari panggilan API
sebelumnya untuk produk tersebut.
Berikut adalah contoh isi JSON untuk insert
dua kaus ke dalam database Merchant Center
menggunakan satu panggilan 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"
]
}
}
]
}
Panggilan API yang berhasil akan menampilkan kode HTTP 200
dan respons JSON yang
menyertakan produk yang disisipkan. Format JSON yang ditampilkan
mirip dengan berikut ini:
{
"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
URL permintaan berikut melakukan panggilan products.custombatch
dengan
method=get
:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
Untuk mendapatkan produk, tentukan batchId
yang unik bagi produk
untuk panggilan API, merchantId
penjual yang diberi otorisasi untuk melakukan
panggilan API, metode get
, dan productId
produk yang diambil.
Berikut adalah contoh isi permintaan JSON untuk mengambil dua produk yang disisipkan menggunakan contoh custombatch:insert
sebelumnya, yang ditentukan oleh nilai productId
-nya. batchId
bersifat unik untuk setiap item dalam daftar:
{
"entries": [
{
"batchId": 1113,
"merchantId": 1234567,
"method": "get",
"productId": "online:en:US:1111111111"
},
{
"batchId": 1114,
"merchantId": 1234567,
"method": "get",
"productId": "online:en:US:2222222222"
}
]
}
Panggilan ini akan menampilkan kode HTTP 200
dan isi respons berikut:
{
"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
URL permintaan berikut digunakan untuk membuat products.custombatch
dengan
method=delete
:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
Untuk menghapus produk, tentukan batchId
yang unik untuk
produk dalam panggilan API ini, merchantId
penjual yang diizinkan
untuk melakukan panggilan API ini, metode delete
, dan productId
produk
yang dihapus.
{
"entries": [
{
"batchId": 1115,
"merchantId": 1234567,
"method": "delete",
"productId": "online:en:US:1111111111"
},
{
"batchId": 1116,
"merchantId": 1234567,
"method": "delete",
"productId": "online:en:US:2222222222"
}
]
}
Panggilan ini menampilkan kode HTTP 200
dan nilai batchId
dari item yang
dihapus:
{
"kind": "content#productsCustomBatchResponse",
"entries": [
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1115
},
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1116
}
]
}