I'm currently encountering an issue while using the Facebook Business SDK to interact with the Insights API. Specifically, when making requests to retrieve insights data, I'm encountering an error response (shown below) intermittently.
facebook_business.exceptions.FacebookRequestError:
Message: Call was not successful Method: GET Path: https://graph.facebook.com/v19.0//insights Params: {'after': 'MzA2MjQZD'}
Status: 400 Response: { "error": { "message": "(#100) Cannot include account_name, objective, clicks, inline_link_clicks, unique_ctr, spend, video_play_curve_actions, conversion_rate_ranking, unique_inline_link_click_ctr, video_p50_watched_actions, cpp, inline_post_engagement, unique_link_clicks_ctr, engagement_rate_ranking, campaign_name, cost_per_inline_post_engagement, video_30_sec_watched_actions, reach, adset_id, unique_clicks, frequency, cost_per_unique_click, website_ctr, impressions, cpc, video_p100_watched_actions, video_p75_watched_actions, canvas_avg_view_time, cpm, adset_name, campaign_id, ad_id, quality_ranking, ctr, cost_per_inline_link_click, canvas_avg_view_percent, ad_name, inline_link_click_ctr, unique_inline_link_clicks, video_p25_watched_actions, account_id, cost_per_unique_inline_link_click in summary param because they weren't there while creating the report run. All available values are: ", "type": "OAuthException", "code": 100, "fbtrace_id": "Aq91qohnOPYMh1BOThG0rvR" } }
The error message suggests that the metrics were not specified when creating the report run, but I have verified that they were indeed included.
I would appreciate any assistance in resolving this issue. Thank you!
Here are the logs containing the stack trace to assist you in resolving the issue.
2024-03-13 08:03:32,495Z tap - Traceback (most recent call last): 2024-03-13 08:03:32,495Z tap - File "/code/orchestrator/tap-env/lib/python3.11/site-packages/tap_facebook/init.py", line 918, in main_impl 2024-03-13 08:03:32,495Z tap - do_sync(account, catalog, args.state) 2024-03-13 08:03:32,496Z tap - File "/code/orchestrator/tap-env/lib/python3.11/site-packages/tap_facebook/init.py", line 807, in do_sync 2024-03-13 08:03:32,496Z tap - for message in stream: 2024-03-13 08:03:32,496Z tap - File "/code/orchestrator/tap-env/lib/python3.11/site-packages/tap_facebook/init.py", line 713, in iter 2024-03-13 08:03:32,496Z tap - for obj in job.get_result(): 2024-03-13 08:03:32,496Z tap - File "/code/orchestrator/tap-env/lib/python3.11/site-packages/facebook_business/api.py", line 789, in next 2024-03-13 08:03:32,496Z tap - if not self._queue and not self.load_next_page(): 2024-03-13 08:03:32,496Z tap - ^^^^^^^^^^^^^^^^^^^^^ 2024-03-13 08:03:32,496Z tap - File "/code/orchestrator/tap-env/lib/python3.11/site-packages/facebook_business/api.py", line 841, in load_next_page 2024-03-13 08:03:32,496Z tap - response_obj = self._api.call( 2024-03-13 08:03:32,496Z tap - ^^^^^^^^^^^^^^^ 2024-03-13 08:03:32,496Z tap - File "/code/orchestrator/tap-env/lib/python3.11/site-packages/facebook_business/api.py", line 350, in call 2024-03-13 08:03:32,496Z tap - raise fb_response.error() 2024-03-13 08:03:32,496Z tap - facebook_business.exceptions.FacebookRequestError: 2024-03-13 08:03:32,496Z tap - 2024-03-13 08:03:32,496Z tap - Message: Call was not successful 2024-03-13 08:03:32,496Z tap - Method: GET 2024-03-13 08:03:32,496Z tap - Path: https://graph.facebook.com/v19.0//insights 2024-03-13 08:03:32,497Z tap - Params: {'after': 'MjIwMjQZD'} 2024-03-13 08:03:32,497Z tap - 2024-03-13 08:03:32,497Z tap - Status: 400 2024-03-13 08:03:32,497Z tap - Response: 2024-03-13 08:03:32,497Z tap - { 2024-03-13 08:03:32,497Z tap - "error": { 2024-03-13 08:03:32,497Z tap - "message": "(#100) Cannot include spend, objective, reach, video_p25_watched_actions, cost_per_inline_post_engagement, frequency, canvas_avg_view_percent, account_name, cost_per_unique_click, unique_ctr, engagement_rate_ranking, inline_link_clicks, video_p50_watched_actions, video_play_curve_actions, ad_id, adset_name, canvas_avg_view_time, inline_link_click_ctr, quality_ranking, conversion_rate_ranking, unique_inline_link_click_ctr, video_30_sec_watched_actions, impressions, ctr, video_p100_watched_actions, account_id, cpm, ad_name, video_p75_watched_actions, unique_inline_link_clicks, campaign_id, website_ctr, unique_link_clicks_ctr, unique_clicks, campaign_name, inline_post_engagement, cost_per_unique_inline_link_click, cost_per_inline_link_click, cpp, cpc, clicks, adset_id in summary param because they weren't there while creating the report run. All available values are: ", 2024-03-13 08:03:32,497Z tap - "type": "OAuthException", 2024-03-13 08:03:32,497Z tap - "code": 100, 2024-03-13 08:03:32,497Z tap - "fbtrace_id": "AGaMoLnWoEzJDtzjLyPUelZ" 2024-03-13 08:03:32,497Z tap - } 2024-03-13 08:03:32,497Z tap - }
The error originates from the SDK, specifically from the api.py file, in the definition load_next_page. https://github.com/facebook/facebook-python-business-sdk/blob/main/facebook_business/api.py#L813
Please note that I intentionally removed the ID from the Graph API endpoint for security reasons.
It seems like you're encountering an error related to the parameters you're passing when making requests to retrieve insights data using the Facebook Business SDK. The error message indicates that certain metrics cannot be included in the summary parameter because they weren't specified when creating the report run, despite your verification that they were included.
Here are a few steps you can take to troubleshoot and potentially resolve this issue:
Review Parameters: Double-check the parameters you're passing when making the request to retrieve insights data. Ensure that all required parameters are included and correctly formatted. Pay special attention to the metrics that are mentioned in the error message and confirm that they are indeed included in the request.
Check API Version: Make sure that you're using the correct version of the Graph API when making requests. The error message includes the API version (v19.0), so ensure that this version supports the parameters and metrics you're trying to retrieve. You may need to update the API version if necessary.
Verify Permissions: Ensure that your app has the necessary permissions to access the insights data you're trying to retrieve. Check the permissions requested during the authentication process and verify that they include the necessary access to insights data.
Test with Different Metrics: If possible, try making requests with a different set of metrics to see if the issue persists. This can help determine if the problem is specific to certain metrics or if it's a more general issue with the request parameters.
Check for Updates: Ensure that you're using the latest version of the Facebook Business SDK. There may be updates or bug fixes that address issues related to insights data retrieval.
Review Documentation: Consult the official Facebook Developer documentation for the Insights API and the Facebook Business SDK to ensure that you're following the correct guidelines and best practices for making requests and handling responses.
If you've tried these steps and are still encountering issues, you may need to reach out to Facebook Developer Support for further assistance. Provide them with detailed information about the error message and the steps you've taken to troubleshoot the issue, including any relevant code snippets. They may be able to provide additional insights or assistance in resolving the problem.
It seems like this is a problem on Meta side. Have been getting the same error for the last month. Although it's not a solution, catching this specific error and retrying the same api call after a couple of minutes has helped me not get the same error again.
I'm also experiencing this issue across a range of customers, our first occurrence was on the 14th of March.
me too
I also have the same problem, it happens occasionally and just on some customers
We are also experiencing this occasionally. It is a sporadic error and definitely a bug/issue with the API, not how the API is being called.