google-apps-script - UrlFetchApp 在每次调用时返回错误 404
问题描述
今天突然间,我在使用带有 UrlFetchApp 的脚本时开始收到错误 404,该脚本直到昨天都运行良好。
我的脚本如下:
const url = ScriptApp.getService().getUrl() + "?function=";
function doGet(e) {
if (e.parameter.function == "Protect") {
script();
return ContentService.createTextOutput();
}
else if (e.parameter.function == "AddRows" ) {
Addrows(e.parameter.sheetName,e.parameter.notoAdd);
return ContentService.createTextOutput();
}
else { // do something by default if there are no url parameters
throw new Error("function was not found.");
}
}
function Protect() {
UrlFetchApp.fetch(url + "Protect", {headers: {authorization: "Bearer " + ScriptApp.getOAuthToken()}});
}
消息详细信息异常:对https://script.google.com的请求失败,返回代码 404。截断的服务器响应:<meta name="viewport" c...(使用 muteHttpExceptions 选项检查完整响应)
当使用选项 muteHttpExceptions : flase 时,会产生相同的错误。
请让我知道脚本中突然发生了什么变化,因为我在其他各种代码中也遇到了同样的错误。
解决方案
推荐阅读
- javascript - this.context 在 jest/Enzyme 中为空
- django - Django Admin“TypeError int() 参数必须是字符串、类似字节的对象或数字,而不是‘汽车’”
- r - Is there a way to convert a .csv format embedded in a website to an actual csv to use read.csv() on?
- node.js - 反应应用程序中的 Jwt 授权,而不将令牌存储在本地存储中
- php - 删除 laravel 护照用户令牌
- javascript - Gatsby gatsby-remark-relative-images 不会将 yaml 绝对图像路径转换为相对路径
- asp.net-core - 如何在 Blazor 中直接更改 css(无变量)?
- php - 如何使用 PHP 向 Vimeo API 发出经过身份验证的 GET 请求?
- aws-lambda - 使用 lambda API 作为存储在 S3 中的内容的反向代理?
- google-apps-script - 使用 Google Apps 脚本 Web 应用打开电子表格