I am trying to fetch reporting for the AdCampaign let’s say with xyz id, I have valid access token with ads_read, read_insights permissions & everything else except page_messaging. The app with the permitted token is owned by same ad account as well.
xyz/insights?fields=ad_name,....
No matter which fields I ask for, it always return me empty data set.
{
"data": [
]
}
2
Answers
For awhile I also struggled with this issue.
What is probably going on is that no ads are being returned for the default parameters of the query. For example, by default Ad Insights looks at only the last 30 days of the advertisement’s lifetime. Try setting the ‘date_preset’ parameter to ‘lifetime’. For your query that would look like:
For more info, check this page: https://developers.facebook.com/docs/marketing-api/reference/adgroup/insights/.
@Dario-macieira is correct but now the date_preset = lifetime parameter is disabled in Graph API v10.0+ and replaced with date_preset = maximum, which returns a maximum of 37 months of data.
For v9.0 and below, date_preset = maximum will be enabled on May 25, 2021, and any lifetime calls will default to maximum and return only 37 months of data.
https://developers.facebook.com/docs/marketing-api/insights/parameters/v12.0