3

I'm getting an error using amazon advertising API. I'm currently trying to request performance report using https://advertising-api.amazon.com/v1/campaigns/report. But the server reply Cannot consume content type

here is my request header and body.

End point : https://advertising-api.amazon.com/v1/campaigns/report

Method Type: POST

Header :

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

Body :

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

I think I did everything correctly as API document but it says

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

Please help me.

enter image description here

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Alex
  • 1,148
  • 8
  • 30

3 Answers3

1

Try this way

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"
    }

And you will get a response like

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

You can put this curl command in Postman also.

Allwin
  • 2,060
  • 1
  • 17
  • 16
1

I think your Body may be missing a parameter. When I successfully make a similar POST I need my body to have at least what you have written as well as the segment type. Try adding this to your body:

{
campaignType:'sponsoredProducts',
reportDate:'20180320',
metrics:'impressions,clicks'
segment:'query'
}
Michael
  • 333
  • 2
  • 10
0

Just copy the body from the documentation and paste it in the raw area (of postman) and choose JSON format. For me it works fine.

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51