通过 google 购物添加产品 json API 400 必须指定产品

Adding product via google shopping json API 400 must specify product

我在使用 google 购物 API (https://developers.google.com/shopping-content/v2/reference/v2/products/insert). I'm sending an authenticated post request to https://www.googleapis.com/content/v2/shop_id/ products?dryRun=true 但仅获取状态:400 错误消息:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "[product] INSERT request must specify product"
   }
  ],
  "code": 400,
  "message": "[product] INSERT request must specify product"
 }
}

我的请求如下所示(为简洁起见缩短并加密 ssl)

POST /content/v2/<removed>/products?dryRun=true HTTP/1.1
Host: www.googleapis.com
Content-Length: 2102
accept-encoding: gzip, deflate
authorization: Bearer <removed>
user-agent: Python-httplib2/0.9.1 (gzip)

{
  "offerId": 4572, 
  "gtin": "4048669296057", 
  "googleProductCategory": "Apparel & Accessories > Clothing", 
  "targetCountry": "se", 
  "title": "Puma Sweat Pants", 
  "onlineOnly": true, 
  "price": {
    "currency": "SEK", 
    "value": "1337"
  }, 
  "channel": "online", 
  "contentLanguage": "sv", 
  "brand": "Puma", 
  "link": "http://example.com/produkt/puma-sweat-pants"
}

我知道请求已正确验证,因为我可以删除验证并获得不同的消息。 Google 的常见错误页面 (https://developers.google.com/shopping-content/v2/how-tos/common-errors) suggests that this is a batch job, but that would be the url https://www.googleapis.com/content/v2/products/batch

我找到了麻烦的原因:我没有发送 Content-Type: application/json header。