"Unexpected error" thrown when using UrlFetch

198 views Asked by At

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

There are 1 answers

0
ziganotschka On

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.