Reputation: 1172
Im trying to query the costs of my facebook campaigns with a python script. For now i think the sample code they generate for you is ok, but im getting this error:
Unsupported get request. Object with ID 'XXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. And i cant figure out what im doing wrong. For the access token im generating one on the Marketing API Configuration.
Any idea what i skipped or did wrong?
The app has the ad account added to it from both the app configuration and the business configuration:
Here is the sample code im using:
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adsinsights import AdsInsights
from facebookads.api import FacebookAdsApi
access_token = 'xxx'
ad_account_id = 'xxx'
app_secret = 'xxx'
FacebookAdsApi.init(access_token=access_token)
fields = [
'today_spend',
]
params = {
'time_range': {'since':'2017-07-03','until':'2017-08-02'},
'filtering': [],
'level': 'campaign',
'breakdowns': [],
}
print AdAccount(ad_account_id).get_insights(
fields=fields,
params=params,
)
Upvotes: 0
Views: 551
Reputation: 1172
The solution was really dumb, i was missing 'act_' before the ad_account_id number.
Upvotes: 1