适用于产品的Google Content API自定义批处理不起作用

对于一个项目,我必须在Google Merchant Center中自动化产品的更新过程。这些产品是通过以Google表格作为输入方法的Feed添加的。这是“主要供稿”。

根据v2.1 api的文档,可以通过补充Feed来完成通过主Feed添加的产品更新(请参见:https://developers.google.com/shopping-content/guides/products/supplemental-feeds/using-supplemental-feeds)。此补充Feed仅允许更新部分产品属性。

使用补充Feed的Feed ID,我可以插入单个产品。但是,由于api http请求限制和要更新的大量产品,我需要使用批处理方法。不幸的是,我似乎无法正常工作。

TL; DR插入单个产品有效,但是使用custombatch方法插入产品无效。批处理方法的响应似乎还可以,但对Google Merchant Center仪表板没有影响。

实施

服务:

service = build('content','v2.1',credentials=scoped_credentials)

通过我的补充Feed更新单个产品可以使用以下代码。

/*
product = {'title': 'Single update 12-42','price': {'value': '69','currency': 'EUR'},'offerId': 'abcd1','contentLanguage': 'en','targetcountry': 'NL','channel': 'online','availability': 'out of stock'}
*/
result = service.products().insert(merchantId=MERCHANT_ID,body=product,feedId=FEED_ID).execute()
/*
result = {'kind': 'content#product','id': 'online:en:NL:abcd1','channel': 'online'}
*/

但是,通过批处理请求进行更新没有效果。

/*
body = {'entries': [{'batchId': 1,'merchantId': MERCHANT_ID,'method': 'insert','feedId': FEED_ID,'product': {'title': 'Batch update 12-44','offerId': 'abcd2','availability': 'out of stock'}}]}
*/
result = service.products().custombatch(body=body).execute()
/*
result = {'kind': 'content#productsCustomBatchResponse','entries': [{'kind': 'content#productsCustomBatchResponseEntry','batchId': 1,'product': {'kind': 'content#product','id': 'online:en:NL:abcd2','channel': 'online'}}]}
*/

值得注意的是,我确实收到了有效的答复,没有任何错误。但是,使用批处理方法(在单个插入项中)对商人中心仪表板没有影响。

还有其他人遇到相同的问题,还是我错过了什么?

iCMS 回答:适用于产品的Google Content API自定义批处理不起作用

我在集成 Node 客户端库时遇到了同样的问题。经过一番研究,我在 GitHub 上找到了这个问题的答案。

您需要添加一个包含“条目”的“资源”字段,因为它们是作为正文的一部分发送的。您可以参考 GitHub 问题 here

将代码中的正文更改为:

body = {'resource': {'entries': [{'batchId': 1,'merchantId': MERCHANT_ID,'method': 'insert','feedId': FEED_ID,'product': {'title': 'Batch update 12-44','price': {'value': '69','currency': 'EUR'},'offerId': 'abcd2','contentLanguage': 'en','targetCountry': 'NL','channel': 'online','availability': 'out of stock'}}]}}
本文链接:https://www.f2er.com/1670687.html

大家都在问