1

I have an access token for Facebook Audiences but I am not able to get create a custom audience using Python-SDK

First I get information about USER id using the following link:

https://developers.facebook.com/tools/debug/accesstoken

Than I use the following URL to list Ad ID's from my account:

https://graph.facebook.com/v3.2/MY_USER_ID/adaccounts

It returns a json with a list of act's like this:

{ "data": [ { "account_id": "xxxx", "id": "act_xxxx" } ] }

With this ID I try to create a new audience:

from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.customaudience import CustomAudience
from facebook_business.api import FacebookAdsApi

id = 'act_xxxx'

FacebookAdsApi.init(access_token='MY TOKEN')

fields = [
]

params = {
  'name': 'My new Custom Audience',
  'subtype': 'CUSTOM',
  'description': 'People who purchased on my website',
  'customer_file_source': 'USER_PROVIDED_ONLY',
}

print(AdAccount(id).create_custom_audience(
  fields=fields,
  params=params,
))

Then the code produces the following error:

Unsupported post request. Object with ID 'act_xxxx' does not exist, cannot be loaded due to missing permissions, or does not support this operation.

I know that this ID exists because it was returned by the previous call. Debugging the access token I can see it has the following access:

read_insights, read_audience_network_insights, publish_video, manage_pages, pages_manage_cta, pages_manage_instant_articles, pages_show_list, publish_pages, read_page_mailboxes, ads_management, ads_read, business_management, pages_messaging, pages_messaging_phone_number, pages_messaging_subscriptions, instagram_basic, instagram_manage_comments, instagram_manage_insights, leads_retrieval

Can anyone help me to discover the reason of this error?

Thanks!

briba
  • 2,857
  • 2
  • 31
  • 59
  • Very strange, have you tried `id = 'xxxx'` instead of `id = 'act_xxxx'`? The doc is not so clear... – Matteo Mar 28 '19 at 16:22
  • try also with the curl or graph api explorer in order to check if the problem is related to the token or not – Matteo Mar 28 '19 at 16:23
  • Maybe the ad_account is not valid? If there is an error with the credit card of the business related to that account it will block the account and make it unusable, getting that error, so that could be one of the reasons – Oscar Garcia - OOSS Jan 08 '21 at 17:53

0 Answers0