facebook-business-sdk-codegen icon indicating copy to clipboard operation
facebook-business-sdk-codegen copied to clipboard

Application Permission error when using creative_sourcing_spec

Open Douglas42digital opened this issue 6 months ago • 0 comments

Checklist

  • [x] I've updated to the latest released version
  • [x] I've searched for existing GitHub issues
  • [x] I've looked for existing answers on Stack Overflow and the Facebook Developers Group
  • [x] I've read the Code of Conduct
  • [x] This issue is not security related and can safely be disclosed publicly on GitHub

Environment

python environment

Goals

I want to create ads with site links using the 'creative_sourcing_spec' key in Adcreative

Expected Results

Ads created with sitelinks

Actual Results

Status: 400 Response: { "error": { "message": "(#10) Application does not have permission for this action", "type": "OAuthException", "code": 10, "fbtrace_id": "A4tpKntRJhpF3ww0FQjvqyH" } }

Steps to Reproduce

Try creating an ad using creative_sourcing_spec

Code Samples & Details

ad_account_id = 'act_70xxxxx'

FacebookAdsApi.init(access_token=fb_access_token,api_version='v20.0')

sitelinks = [
    {
        'site_link_title':'Link 1 Title',
        'site_link_url':'https://example.com/link1'
    },
   {
       'site_link_title':'Link 2 Title',
       'site_link_url':'https://example.com/link2'
   },
     {
       'site_link_title':'Link 3 Title',
       'site_link_url':'https://example.com/link3'
   }
]

promotion_metadata = [
    {
        'end_date': 1627776000,
        #'id': 'id_string',# valid offer_id
        'promotion_source': 'ADVERTISER_INPUT'
        'promotion_type': 'PERCENTAGE_OFF',
        'promotion_value': 10.0,
        'required_code': 'SUMMER10',
        'start_date': 1625097600,
    } 
]

creative_sourcing_spec = {
    "site_links_spec": sitelinks,
    "promotion_metadata_spec": promotion_metadata,
    "source_url": 'https://www.digital.de'
}

# Create the ad creative
creative_params = {
    'name': 'Your Ad Creative Name',
   
    'object_story_spec': {
        'page_id': page_id ,
         'instagram_actor_id':instagram_page_id,
        'link_data': {
            'link': 'https://www.digital.de',
            'message': 'Testing Your ad message',
            'name': 'Testing Your headline',
            'description': 'Testing Your ad description',
        }
       
    },
        'contextual_multi_ads': {
                 "enroll_status": "OPT_IN"
             },
             "degrees_of_freedom_spec": {
        "creative_features_spec": {
            "standard_enhancements": {
                "enroll_status": "OPT_IN"
            }
        }
        },
       'creative_sourcing_spec': creative_sourcing_spec

}
ad_creative = AdAccount(ad_account_id).create_ad_creative(fields=[], params=creative_params)
ad_params = {
        'name': 'Testing Site Links and Offers Ad Name',
        'adset_id': 238xxxxxxxx,
        'creative': {'creative_id': ad_creative['id']},
        'status': 'PAUSED',
    }
AdAccount(ad_account_id).create_ad(fields=[], params=ad_params)

Douglas42digital avatar Jul 31 '24 12:07 Douglas42digital