I am trying to get the campaigns list from the Graph API Explorer. I’m using the request found at https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns/
.
GET /v2.8/{ad-account-id}/campaigns HTTP/1.1
Host: graph.facebook.com
I’m’ business manager and admin of the page used for ads. I found the AD_ACCOUNT_IDs
using the following request on the Graph API Explorer.
GET /v2.8/me/businesses HTTP/1.1
Host: graph.facebook.com
I choosed the one which had the higher privileges.
The error reported when submitting the first request for campaigns is:
{
"error": {
"message": "Unsupported get request. Object with ID '1015359838XXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "DLyfwGbM8fi"
}
}
What’s wrong?
Thanks in advance,
Mattia
2
Answers
I similarly was having problems trying to retrieve a list of all campaign IDs within an ad account.
I already am able to retrieve campaign data by ID, so I obviously have permissions already.
But the Facebook error message is misleading.
When retrieving an ad account (in order to then display its campaigns or whatever you want within it), you need to retrieve by its ID prepended with ‘act_’.
E.g you could request
/act_123456789000001234/campaigns
instead of/123456789000001234/campaigns
.Thanks so much to @Jan Sommer at https://stackoverflow.com/a/39974857/470749.
@Ryan’s answer saved my day. It may sound stupid/silly but I was doing this mistake and I was just stuck at it.
Going through the FB docs for using the Marketing Apis.
I was trying to build the custom audience, this is how the curl request looks like –
One of the basic things to keep in mind while using the Marketing API is, almost all the APIs ask for these two things –
1) ACCESS_TOKEN
2) AD_ACCOUNT_ID
For people who are just starting with the FB Marketing API or somehow stuck in finding these values, I will just tell you how to get these values, so that you don’t have to waste your time as I did.
So for getting the ACCESS_TOKEN, go to your app dashboard then click
Add Product
and then selectMarketing API
. Once you added the product, this is how the screen should look like –Now just check the permissions and click on the
Get Token
button, a token would be generated. Just copy the token in some file and save it.Now for getting the
AD_ACCOUNT_ID
value, just go to theAdverts Manager
page –The number that is written inside the red box in you
Adverts Manager
page is yourAD_ACCOUNT_ID
.The final step would be to go back to you app dashboard again,
Settings > Advanced
Click on
Ads API
and then enter theAD_ACCOUNT_ID
here. Thats it, you have finished theAccess and Authentication
process for using the marketing API via your App.Now comes the part where I was doing the silly mistake. The curls request looks like this –
First I replaced
ACCESS_TOKEN
with its value.Then instead of replacing only the
<AD_ACCOUNT_ID>
I replaced the whole stringact_<AD_ACCOUNT_ID>
, with the AD_ACCOUNT_ID value.So I was getting this error while making request to the API which was –
I don’t know why I made this mistake but I am sure this is one of the common mistake others are doing too. Since the response from FB was misleading, I wasted a lot of my time in understanding and reading on the API permissions and authentications.
Hope this article was helpful and save your time.