亚马逊 - 无法使用Advertising API

时间:2018-03-22 10:50:59

标签: amazon-advertising-api

我使用亚马逊广告API收到错误。我目前正在尝试使用https://advertising-api.amazon.com/v1/campaigns/report请求效果报告。 但服务器回复Cannot consume content type

这是我的请求标题和正文。

结束点:https://advertising-api.amazon.com/v1/campaigns/report

方法类型:POST

标题:

{
     Authorization: 'Bearer xxxxxx',
     Amazon-Advertising-API-Scope: '11111111111',
     Content-Type: 'application/json'
}

身体:

{
    campaignType:'sponsoredProducts',
    reportDate:'20180320',
    metrics:'impressions,clicks'
}

我认为我作为API文档正确地做了所有事情,但它说

{ "code": "415", "details": "Cannot consume content type" }

请帮帮我。

enter image description here

3 个答案:

答案 0 :(得分:1)

尝试这种方式

curl -X POST \
  https://advertising-api.amazon.com/v1/campaigns/report \
  -H 'Amazon-Advertising-API-Scope: REPLACE_YOUR_PROFILE_ID' \
  -H 'Authorization: REPLACE_YOUR_ACCESS_TOKEN' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -H 'Host: advertising-api.amazon.com' \
  -H 'cache-control: no-cache' \
  -d '{
      "campaignType": "sponsoredProducts",
      "metrics": "impressions,clicks",
      "reportDate": "20181101"
    }

您会收到类似

的答复
{
  "reportId": "amzn1.clicksAPI.v1.p1.......",
  "recordType": "campaign",
  "status": "IN_PROGRESS",
  "statusDetails": "Report is being generated."
}

您还可以将curl命令放在Postman中。

答案 1 :(得分:0)

只需从文档中复制正文并将其粘贴到(邮递员的)原始区域中,然后选择JSON格式即可。对我来说,它工作正常。

答案 2 :(得分:0)

我认为您的身体可能缺少参数。当我成功进行类似的POST时,我需要我的身体至少具有您编写的内容以及段类型。尝试将其添加到您的身体中:

{
campaignType:'sponsoredProducts',
reportDate:'20180320',
metrics:'impressions,clicks'
segment:'query'
}