facebook / facebook-python-business-sdk

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

Ad Campaign get_insights by date and country not working #496

Closed nskybytskyi closed 6 years ago

nskybytskyi commented 6 years ago

I am trying to get insights about a specific ad campaign on specific date broken down by country. My code is as follows:

_fields=['impressions', 'spend']
_params={'breakdowns':'country',
         'time_range': {'since': '2018-07-15', 
                        'until': '2018-07-15'}}
campaign.get_insights(fileds=_fields, params=_params)

I get the following error:

UserWarning: value of breakdowns might not be compatible.
Expect list<breakdowns_enum>;  got <class 'str'>

Is there anything I am doing wrong, or is it a mistake in sdk?

ntnam11 commented 6 years ago

The error said that breakdowns parameters must be a list. Try changing 'breakdowns': 'country' to 'breakdowns': ['country']

jingping2015 commented 6 years ago

close it since @ntnam11 provide a correct way to fix it.