Alışveriş Content API'sinde bir toplu istek birden fazla girişe sahip olabilir ve her giriş kaynakta tanımlanan herhangi bir yöntem (ekle, güncelle, sil veya özel) olabilir.
Merchant API, özel toplu istek yöntemleri sunmaz. Bunun yerine, istekleri paralel olarak yürütebilirsiniz.
İstemci kitaplığıyla
İstemci kitaplığını kullanıyorsanız bu Shopping Content API kodunu kullanabilirsiniz.
ProductsCustomBatchResponse batchResponse =
content.products().custombatch(batchRequest).execute();
Merchant API eşdeğerini aşağıdaki gibi yazın.
List<ApiFuture<ProductInput>> futures;
for (InsertProductInputRequest request : requests) {
futures.add(productInputsServiceClient.insertProductInputCallable().futureCall(request));
}
List<ProductInput> responses;
for (ApiFuture<ProductInput> future : futures) {
responses.add(future.get());
}
İstemci kitaplığı olmadan
İstemci kitaplığını kullanmıyorsanız Tek seferde birden fazla istek gönderme bölümünde açıklandığı şekilde gruplandırmayı tamamlayın.
Örneğin, aşağıdaki gibi bir Content API for Shopping isteğini değiştirin:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
{
"entries": [
{
"method": "insert",
"product": { … }
} … ]
}
Toplu istek yazma örneğini inceleyin.