我正在尝试使用以下 node.js 代码将产品插入 Google Shopping API,但我不断收到错误消息:
{ [Error: [product] INSERT request must specify product]
code: 400,
errors:
[ { domain: 'global',
reason: 'required',
message: '[product] INSERT request must specify product' } ] }
这是我的javascript代码(我在这里使用节点客户端:https ://github.com/google/google-api-nodejs-client/ ):
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(*OAUTHDETAILS*);
oauth2Client.setCredentials({
access_token: '*ACCESSTOKEN*',
//refresh_token: 'REFRESH TOKEN HERE'
});
var content = google.content({ version: 'v2', auth: oauth2Client });
var product = {
"channel": "online",
"contentLanguage": "en",
"offerId": *PRODUCTID*,
"targetCountry": "us",
"identifierExists": false,
"condition": "new",
"link": "*PRODUCTLINK*",
"price": {
"currency": "usd",
"value": *VALUE*
},
"title": *PRODUCTTITLE*,
"availability": "in stock",
"description": *DESCRIPTION*,
"googleProductCategory": *PRODUCTCATEGORY*,
"ageGroup": "adult",
"color": *PRODUCTCOLOR*,
"gender": "unisex",
"sizes": [
"XS",
'S',
'M',
'L',
'XL'
],
"imageLink": *IMGURL*
};
content.products.insert({merchantId:*MERCHANTID*,product:product},function(err, resp) {
// handle err and response
console.log(err);
console.log(resp);
});
提前感谢您的帮助!