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/
@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 select Marketing 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 the Adverts Manager
page -
The number that is written inside the red box in you Adverts Manager
page is your AD_ACCOUNT_ID
.
The final step would be to go back to you app dashboard again, Settings > Advanced
Click on Ads API
and then enter the AD_ACCOUNT_ID
here. Thats it, you have finished the Access 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 -
curl \
-F 'name=My new CA' \
-F 'subtype=CUSTOM' \
-F 'description=People who bought from my website' \
-F 'access_token=' \
https://graph.facebook.com/v2.8/act_/customaudiences
First I replaced ACCESS_TOKEN
with its value.
Then instead of replacing only the
I replaced the whole string act_
, with the AD_ACCOUNT_ID value.
So I was getting this error while making request to the API which was -
{"error":{"message":"Unsupported post request. Object with ID '120574219' 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":"YsSvKKwgLMQ"}}
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.