I need to export campaign statistics to .xlsx, which is stored in Google Drive. I substitute the link to this document in the script, and I get this error:
"Service Spreadsheets failed while accessing document with id 1S_rjqsgbjyTKXEo14j_m2xtoIwgHCFi1. (file Code.gs, line 18)".
In the privacy parameters of the document, "editing for everyone who has the link" is configured. How do I solve the problem? I tested these two links: https://docs.google.com/spreadsheets/d/1S_rjqsgbjyTKXEo14j_m2xtoIwgHCFi1/edit#gid=1649084583/ https://drive.google.com/file/d/1S_rjqsgbjyTKXEo14j_m2xtoIwgHCFi1/view?usp=sharing
Here is the script itself.
function main() { // var url = 'https://drive.google.com/file/d/1S_rjqsgbjyTKXEo14j_m2xtoIwgHCFi1/view?usp=sharing/'; var datasheet = 'Ali_web_all_acc_export.xlsx'; var columns = 'CampaignName, AdvertisingChannelType, Cost, Date'; var report = 'CAMPAIGN_PERFORMANCE_REPORT'; var selector = 'CampaignName DOES_NOT_CONTAIN "Шашлык15loooool"'; var during = 'YESTERDAY'; // Функция выгрузки exportReportToSpreadsheet(url, datasheet, columns, report, selector, during); } function exportReportToSpreadsheet(url, datasheet, columns, report, selector, date) { var spreadsheet = SpreadsheetApp.openByUrl(url); var sheet = spreadsheet.getSheetByName(datasheet); var report = AdWordsApp.report( 'SELECT ' + columns + ' ' + 'FROM ' + report + ' ' + 'WHERE ' + selector +' ' + 'DURING '+ date + ' ' ); report.exportToSheet(sheet); }