1

次の 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);
});

助けてくれてありがとう!

4

1 に答える 1