1
我嘗試使用下面的Node.js的代碼中插入一個產品到谷歌購物API,但我不斷收到錯誤:谷歌購物API Node.js的產品說明書申報表「INSERT請求必須註明產品」的錯誤
{ [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);
});
在此先感謝您的幫助!
的參數,因爲它似乎在產品屬性已被命名爲資源的結果。你可以嘗試使用這個對象簽名{merchantId:* MERCHANTID *,資源:產品}? – Boot750
完美!謝謝@ Boot750! – user2890042
我會提供一個awnser,這樣可能會幫助你多一點 – Boot750