问题
I have been using App Scripts to Download and insert CM360 reports into Google Sheets for a while now, but since a couple of days back I get the following error when running the code:
Exception: Unexpected error: https://www.googleapis.com/dfareporting/v3.4/reports/xxx/files/xxx?alt=media (Code:23:56)
Example of the code I am running:
function runreport() {
var reportId = xxx;
var profileId = xxx;
var additionalParameters = {'synchronous': 'true'};
var ReportFile = DoubleClickCampaigns.Reports.Files.list(profileId,reportId);
var ReportFileID = (ReportFile.items[0].id);
var newReportFile = DoubleClickCampaigns.Files.get(reportId, ReportFileID);
if(newReportFile.urls) {var httpOptions = {'headers': {'Authorization':'Bearer ' + ScriptApp.getOAuthToken()}};
var csvContent = UrlFetchApp.fetch(newReportFile.urls.apiUrl, httpOptions).getContentText();
var csvData = Utilities.parseCsv(csvContent);}}
Do anyone else encountered this issue and have managed to solve it?
回答1:
The unexpected error
is due to a new bug with UrlFetchApp
It has already been filed serveral times, e.g. here.
So instead of filing it again you should rather "star" the already existing issue - to increase its visibility.
来源:https://stackoverflow.com/questions/65247137/unexpected-error-thrown-when-using-urlfetch