krish
krish

Reputation: 63

Creating Custom Audience in Facebook marketing api

I am an student and trying to use Facebook marketing api for one of my school project. I am trying to write a program in python to create custom audience in Facebook. I am really confused on how I should be going forward with this. I created an Ads App. I used this app credentials to connect.

my_app_id = 'my_app_id'
my_app_secret = 'my_app_secret'
my_access_token = 'my_access_token'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)

audience = CustomAudience(parent_id='act_my_app_id')
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.custom
audience[CustomAudience.Field.name] = 'Test'
audience.remote_create()

Token access was generated for ads_management and ads_read. However, I get this error

Application does not have the capability to make this API call.

Then I created a Sandbox Ad Account and used its credentials to create the custom audience. I did not get any error but I do not know where I should go to see the custom audience I created. I understand that Sandbox account is not for production but I think I should be able to see my custom audience somewhere.

I am not sure whether the approach I took is correct or not and I highly appreciate if someone could provide me a direction on what should I do to create a custom audience on Facebook. Also, if you find my documentation unclear, please let me know and I will try to add more relevant stuffs. Thank you.

Upvotes: 2

Views: 1135

Answers (1)

Mirella Da Silva
Mirella Da Silva

Reputation: 21

First thing to notice is that you should be using your Ad Account as the parent of the Audience, i.e.:

my_adaccount = 'act_1234';
audience = CustomAudience(parent_id=my_adaccount);

instead of

audience = CustomAudience(parent_id='act_my_app_id');

Another thing is that your app may not have those permissions, you have to ask for Ads Management Basic Access. For more, check the section "Apply for Basic" here: https://developers.facebook.com/docs/marketing-api/access

Upvotes: 1

Related Questions