facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.29k stars 635 forks source link

Problem with API response for huge amount of data #510

Closed smar10 closed 6 years ago

smar10 commented 6 years ago

Hi all, I'm trying to make some calls to the marketing API , but when I define the time_increment as 1 (diary) , and date_preset as lifetime, I get an 500 Status Error. I think this happen because some time out issue or data volume issue.

When I change the time increment to monthly , the API returns all ok . With the graph API explorer, I don't get the same error, and the API returns ~ 4000 records.

Anyone with the same problem ? Thanks

Error : Status: 500 Response: { "error": { "code": 1, "message": "An unknown error occurred", "error_subcode": 99 } }

jingping2015 commented 6 years ago

Can you provide which api endpoint you are calling ? it will be great you can provide a sample code here.

smar10 commented 6 years ago

@jingping2015 the problem it's in insights endpoint. fields = [ 'ad_name', 'campaign_name', 'adset_name', 'reach', 'impressions', 'cpc', 'ctr', 'clicks', 'cost_per_action_type', 'objective', 'frequency', 'spend', 'date_start', 'date_stop', 'relevance_score', 'actions', 'inline_link_clicks', 'unique_clicks', 'action_values', 'ad_id', 'adset_id', 'campaign_id', 'inline_post_engagement' ]

params= { 'level': 'ad', 'filtering':[{'field':"ad.impressions",'operator':"GREATER_THAN",'value':0}], 'breakdowns': [], 'time_increment': 1, 'date_preset':'lifetime' }

res = AdAccount(ad_account_id).get_insights(fields=fields,params=params)

jingping2015 commented 6 years ago

Hi, I test with my adaccount with 'time_increment': 1, get the error code 500

  Status:  500
  Response:
    {
      "error": {
        "message": "Please reduce the amount of data you're asking for, then retry your request",
        "code": 1
      }
    }

If change to monthly, it works fine. So I think you maybe can re-try or download our latest package to test.

smar10 commented 6 years ago

@jingping2015 yes , that's the problem. Why this happen with python sdk and with graph API explorer it's all ok?

It's possible fix this issue?

jingping2015 commented 6 years ago

Can you provide graph explorer success session ? Since I think this error message is from graph api call, not from business sdk.

jingping2015 commented 6 years ago

Hey, thanks for your comment! This is actually an api issue. Please report the issue on Devsite Bug Report channel: https://developers.facebook.com/support/bugs/ Thanks!