I am hitting the /sb/negativeKeywords endpoint and every time I try to make a POST request, I get the following error:
StatusCodeError: 415 - {"code":"415","details":"Cannot consume content type"}
Notice that the documentation asks for a media type of application/vnd.sbnegativekeyword.v3.json.
We are able to hit other V3 endpoints with the same content type like "/sp/targets/keywords/recommendations" using the exact same headers except for "application/vnd.spkeywordsrecommendation.v3+json" as the "Content-Type". It seems that only the /sb/negativeKeywords route is giving us trouble.
Headers for request:
'Amazon-Advertising-API-ClientId': 'amzn1.application-oa2-client.xxxxxxx1',
'Content-Type': 'application/vnd.sbkeywordresponse.v3+json',
Authorization: 'Bearer Atza|IwEBIIPwm8y4K--xxxxxx-lPmAbVKr04Ms96butEfRXw1Lncix13NLSRO_Ww9ScjI_8gCvxxxxx-xxxxxx-xxxxxxx',
'Amazon-Advertising-API-Scope': 123123123123123123
}
Example body that throws error:
[
{
campaignId: 123123123, // valid campaign id
adGroupId: 123123, // valid ad group id
keywordText: 'Keyword 1',
matchType: 'negativeExact'
}
]
What are we doing wrong? We shouldn't be getting this error. We are using the content type that is suggested in the documentation. How would I know if this is an API problem and not a request problem? This is a widely used endpoint so it's very improbable that it's an API issue.
I'm using the following dependencies and node versions:
"request-promise": "4.2.6",
"ts-node": "10.7.0",
Just keep the content-type as 'application/json' and it will resolve the error.
Example:
Results in a [207] SUCCESS response.