Hello guys am stuck with a problem while creating a facebook ads task, am getting an error while i run my code , and the my error is Exception: Request failed for https://www.facebook.com returned code 404. Truncated server response: , if you have any problem please free feel to ask any time.
// MODIFY YOUR SETTINGS HERE //
// url of the google sheets where the report will be
const SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/1h-9f2Au7pBLUTpkOaSEPHJoEN61PQxnlQjczyz6_icU/edit#gid=0'
// name of the sheet where the report will be
const TAB_NAME = 'Facebook'
// DO NOT MODIFY ANYTHING BELOW //
function getFacebookReport() {
// Selects the chosen sheet and tab
const ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
const sheet = ss.getSheetByName(TAB_NAME);
// Clears the sheet
sheet.clear();
// Gets the Facebook report run ID
const cache = CacheService.getScriptCache();
const reportId = cache.get('campaign-report-id');
// Fetches the report as a csv file
const url = `https://www.facebook.com/ads/ads_insights/export_report?report_run_id=${reportId}&format=csv&access_token=${TOKEN}`;
const fetchRequest = UrlFetchApp.fetch(url);
const results = Utilities.parseCsv(fetchRequest);
// Pastes the csv file in the sheet
sheet.getRange(1,1, results.length, results[0].length).setValues(results);
}