【问题标题】:"Unexpected error" thrown when using UrlFetch [duplicate]使用 UrlFetch 时抛出“意外错误”[重复]
【发布时间】:2020-12-11 07:10:04
【问题描述】:

一段时间以来,我一直在使用 App Scripts 下载 CM360 报告并将其插入 Google 表格,但几天前我在运行代码时收到以下错误:

异常:意外错误:https://www.googleapis.com/dfareporting/v3.4/reports/xxx/files/xxx?alt=media(代码:23:56)

我正在运行的代码示例:

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);}}

有其他人遇到过这个问题并设法解决了吗?

【问题讨论】:

  • “查看 URL 时”是什么意思?
  • 此 URL:googleapis.com/dfareporting/v3.4/reports/xxx/files/… 是从应用脚本中的响应推送而来的。但是,我现在意识到,仅来自该 URL 的响应在插入浏览器时会提供身份验证错误,因为我没有将标头/身份验证插入到调用中。
  • @AR 是的,所以 401 无关紧要,唯一相关的部分是“意外错误”
  • 你可能想edit这个问题来反映这一点。此外,谷歌更好地解决了这个问题。在 issuetracker 中创建一个问题,并在此处添加指向该问题的链接作为答案。有关详细信息,请参阅tag info page
  • 是的,我已经编辑了问题并将在 issuetracker 中创建一个问题!谢谢!

标签: google-apps-script double-click-advertising


【解决方案1】:

unexpected error 是由于 UrlFetchApp 的一个新错误造成的

它已经提交了好几次,例如here.

因此,与其重新归档,不如为已经存在的问题“加注星标” - 以提高其知名度。

【讨论】:

    猜你喜欢
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 1970-01-01
    • 2020-06-03
    相关资源
    最近更新 更多