I'm looking to download a CSV from my api call to FB ads, I've set it in the parameters as per the code below, the call works fine but I only get a paginated JSON as a response. I'm not quite sure how to access the CSV report, the response doenst give me any report ID or download link. How can I download this CSV?
Using nodejs facebook-nodejs-ads-sdk image showing the parameter information 'export_format' Documentation: https://developers.facebook.com/docs/marketing-api/reference/adgroup/insights/
var getReport = function(){
console.log("API for FB report has been called")
let ads_insights;
let ads_insights_id;
const logApiCallResult = (apiCallName, data) => {
console.log(apiCallName);
if (showDebugingInfo) {
console.log('Data:' + JSON.stringify(data));
}
};
const fields = [
'ad_name',
'impressions',
'reach',
'spend'
];
const params = {
'export_format': 'csv',
'export_name': new Date() + 'fb-download',
'level' : 'ad',
'filtering' : [],
'breakdowns' : [],
'time_range' : {'since':'2018-01-22','until':'2018-01-23'}
};
new AdAccount(ad_account_id).getInsights(
fields,
params).then((result) => {
logApiCallResult('ads_insights api call complete.', result);
console.log("##########" + result + "#####")
ads_insights_id = result[0].id;
}).catch((error) => {
console.log(error);
});
}