google-apps-script - 谷歌应用脚本,TextOutput 不返回消息
问题描述
故事:我正在测试一个谷歌应用程序脚本,它接收一个文件并向收件人发送一封电子邮件,其中包含一个文件内容作为邮件的正文。我还想让发件人/用户知道“电子邮件发送成功”。
问题:一切正常,直到到达最后一行,
return ContentService.createTextOutput("sent successfully!!!");
它应该将成功消息返回给发件人。但它发送http状态错误[302]。我正在使用 dio 包发送 http post 请求。我也单独测试了返回线,它工作正常。
function doPost(e) {
var blob = Utilities.newBlob(Utilities.base64DecodeWebSafe(e.parameter.file),e.parameter.contentType,e.parameter.fileName);
var body = blob.getDataAsString();
MailApp.sendEmail("testEmail@gmail.com", "this is a test subject", body);
return ContentService.createTextOutput("sent successfully!!!"); //doesnt work
}
这段代码工作得很好:
function doGet() {
return ContentService.createTextOutput("hello world!");
}
我究竟做错了什么?
解决方案
e.parameter
是GET
通常用于GET
请求的参数
你应该使用e.postData
推荐阅读
- android - ccache会影响后续android构建中的错误吗
- android - Kotlin 保持对类的引用并更新
- python - pyqt - 表格中的拖放行无法拖动单元格中的图像和小部件
- wordpress - WP Gutenberg 块回调 - 如何添加动态 CSS(到头部)?
- git - Git 无法正确显示 UTF-8 文件名
- azure-webjobs - 公开部署为 Web 作业的红隼服务器以进行外部交互
- python - Python SQLITE 更新子句未更新
- javascript - 如何使用javascript选择父母的兄弟姐妹的孩子(没有jquery)
- angular - 没有 BsModalService 提供者,我需要更改什么?
- html - HTML responsive navigation show first and last item always