“未找到函数"向 Web 应用程序发出 GET 和 POST 请求时出错 [英] "function not found" error when making both GET and POST requests to a Web App
问题描述
我收到了
Script function not found: doGet
或
Script function not found: doPost
当我 GET/POST 到我的 Google 脚本时:
when I GET/POST to my Google script:
function doGet(e){return ContentService.createTextOutput("User says")}
function doPost(e) {
return HtmlService.createHtmlOutput(
"<form action='http://www.example.com/users/gmail_permission/' method='post' id='foo'>" +
"<input type='hidden' name='gmail' value='getEmail()' >" +
"<input type='hidden' name='id' value='e.parameter.user_id' >" +
"</form>" +
"<script>document.getElementById('foo').submit();</script>");
}
function getEmail() {
return Session.getActiveUser().getEmail();
}
奇怪的是,当我在浏览器上访问 Webapp URL 时,会出现上述错误.但是当我使用 Hurl.it 时,我只是被重定向到 Google Drive.但是当我为您的最新代码测试网络应用程序"时.在 google.script.com 上,GET 响应工作正常.
The weird thing is I'll get the above error when I visit the Webapp URL on my browser. But when I use Hurl.it, I just get redirected to Google Drive. But when I 'Test web app for your latest code.' on google.script.com, the GET response works fine.
完全不知道发生了什么......这是我的脚本:
Pretty lost as to what is going on.... here is my script:
https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec
这里是 GETs
FROM Hurl.it - GET https://accounts.google.com/ServiceLogin?service=wise&followup=https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec&continue=https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec&passive=1209600
FROM script.google.com: https://script.google.com/macros/s/AKfycbyCH4Jk7VcEIhE52jIorIBzcghRYAPRuwuzFSHwaWIB/dev
FROM browser:https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec
推荐答案
终于找到答案了.
这很愚蠢,但显然保存和重新发布您的 google 脚本网络应用程序还不够好.您需要保存新版本并发布新版本,以确保您的应用正确更新.
It's pretty stupid, but apparently saving and republishing your google script web app is not good enough. You need to save a new version and publish the new version to make sure your app gets updated properly.
这篇关于“未找到函数"向 Web 应用程序发出 GET 和 POST 请求时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!