The official documentation for the Amazon Advertising API has some gaps or poorly worded information regarding the proper configuration of calls to the Advertising API. The goal of this post is to provide a clear example of how to properly configure these requests.
Say for example we would like to make a request to one of these endpoints:
For basically all of these endpoints we require the following “parameters”
|Parameter||What it is|
||Valid Amazon profile Access Token|
||The client ID from developer registration process|
||The Advertising Profile ID|
Getting these credentials is a multi-step process. The client ID is a fairly straightforward part of the application to the API so if you are reading this you likely already have this. This ID remains static regardless of which advertising profile we are querying and does not expire. Therefore we will not cover how to obtain this in this post.
The documentation to retrieve the Access Token is covered in reasonable detail, but the exact configuration of the request is tricky. Here is a screenshot of a Postman setup.
Note the very specific
And then for the body note the following settings.
These will vary depending on whether you are exchanging an auth code or a refresh token, but the format is basically the same.
Be absolutely certain that you are not making your secret key publicly available. This request cannot be sent directly from a web application client, it must be sent from a secure server, or if you are running a serverless application architecture, you must route this request through Lambda or a similar service.
At this point we have two of the three key pieces of information that we require to make requests to the advertising API. All we have left is…
Commonly an Amazon account will have access to more than one advertising profile, therefore when we make the request for the profiles information we get back an array of advertising profile data. If the Amazon account does not have access to any advertising profiles the array will be empty.
Note that in this instance we only require the Client ID and User Access Token. Also the body of the request is blank.
We now have the three items that we need we can put together a request to a list of Advertising Campaigns for our chosen advertising profile.
The official documentation refers to the Client ID and Scope as parameters, but they are in fact headers. Adding these items as parameters will fail the request.
Once your request is working properly in Postman you can then convert it to whatever format you like.