ShoppingContent.Products.update无法更新Merchant Center产品
问题:Google Ads脚本更新Merchant Center产品customLabel0不生效
问题详情
已在Google Ads脚本的高级API区域启用Shopping Content权限,尝试通过脚本更新Merchant Center中产品的customLabel0字段。发送请求后能正常获取产品响应,但修改的内容并未在Merchant Center中生效。
使用的更新代码
const resource = { 'customLabel0': label }; ShoppingContent.Products.update(resource, merchantId, id);
收到的响应内容
{ "kind": "content#product", "id": "local:fr:-:kar-240w3884-a-black-tu", "offerId": "kar-240w3884-a-black-tu", "contentLanguage": "fr", "feedLabel": "-", "channel": "local" }
解决方案
更新请求必须包含核心标识字段:Shopping Content API的
Products.update接口要求请求体必须携带contentLanguage、channel、feedLabel这些产品核心上下文字段,仅传customLabel0会导致更新操作被忽略。方案一:先获取完整产品数据再更新
// 获取目标产品的完整信息 const product = ShoppingContent.Products.get(merchantId, id); // 修改customLabel0字段 product.customLabel0 = label; // 提交完整产品对象执行更新 ShoppingContent.Products.update(product, merchantId, id);方案二:手动传入核心字段
const resource = { 'customLabel0': label, 'contentLanguage': 'fr', // 与响应中的值保持一致 'channel': 'local', 'feedLabel': '-' }; ShoppingContent.Products.update(resource, merchantId, id);验证更新结果:执行更新后,调用
Products.get重新获取产品数据,确认customLabel0已变更。Merchant Center后台可能存在几分钟的同步延迟,稍等后再查看后台状态。
内容的提问来源于stack exchange,提问作者Hussnain Saeed
相关产品推荐
相关产品推荐

