post - 如何在 Apps 脚本中创建 POST 请求?
问题描述
我的目标是使用 Gmail API 的上传附件功能。上传的文件将在我的 Gmail 插件中处理。我在此链接中找到了以下 POST 请求。
发布https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=media
到目前为止,这是我的尝试:
function testPOST() {
Logger.log('Testing of POST in Apps script');
// var url = ScriptApp.getService().getUrl();
var url = "https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send"
Logger.log('URL:'+url);
var options =
{
"method" : "POST",
"uploadType" : "media"
};
// Trying to fetch the file
var result = UrlFetchApp.fetch(url, options);
Logger.log('Response code: ' + result.getResponseCode());
// maybe I need to use some function in 'Gmail.Users.*'
}
解决方案
推荐阅读
- r - 从包含 3 个向量的列表中创建一个新向量,但消除重复值
- r - 无法遍历 R 中的数据框行索引
- python-3.x - 将嵌套的 for 循环转换为矢量化形式,以便在使用 numpy 时评估函数
- c++ - 带有ubuntu问题的C ++中的OBJ文件
- android - 每个 dex 文件的最大引用方法数
- javascript - JS函数无法从vbhtml获取值
- shell - 对我的 RPI 切换显示的脚本进行故障排除
- java - 将具有可能序列化 JSON 值的 hashmap 作为节点添加到 JSON 字符串
- c# - 无法使用本地部署的 ASP.NET REST API
- google-cloud-platform - 如何为 Cloud IAM 添加“Google 群组”