I'm trying to fetch insights for my ad sets using the Facebook Graph API. Here are the parameters and the request I'm making:
params_insights_get = { "access_token": "ACCESS_TOKEN", "level": "adset", "fields": "reach,impressions,estimated_ad_recall_rate,frequency,full_view_impressions,full_view_reach,clicks,inline_link_clicks,outbound_clicks,video_play_retention_0_to_15s_actions,video_play_retention_20_to_60s_actions,actions,spend,instagram_upcoming_event_reminders_set,inline_link_click_ctr,outbound_clicks_ctr,unique_inline_link_clicks,cost_per_ad_click,cost_per_conversion,cost_per_one_thousand_ad_impression,cost_per_outbound_click,cost_per_thruplay,cost_per_unique_action_type,cost_per_unique_click,cost_per_unique_inline_link_click,cost_per_unique_outbound_click,cost_per_action_type,cpc,cpm,cpp,ctr,optimization_goal,adset_id,adset_name", } root_url = f"https://graph.facebook.com/v19.0/" campaigns_ext = "/campaigns" adsets_ext = "/adsets" insights_ext = "/insights" response_insights_get = requests.get( root_url + campaign_id + insights_ext, params=params_insights_get )
This was working fine for the last six months. However, recently, I keep getting the following error response:
{ "error": { "message": "Service temporarily unavailable", "type": "OAuthException", "is_transient": False, "code": 2, "error_subcode": 1504018, "error_user_title": "Your request timed out", "error_user_msg": "Please try a smaller date range, fetch less data, or use async jobs", "fbtrace_id": "AvoEH7ogR7jlllCmCC943cH", } }
The date range I need is 7 days, i.e. the default value, and I need all the data in the query. I've tried async jobs, but the jobs keep failing. Interestingly, this only affects one particular campaign in my sample adaccount, the others work fine.