如何在Apps脚本中创建POST请求?

时间:2019-11-20 22:06:22

标签: post google-apps-script

我的目标是使用Gmail API的上传附件功能。上传的文件将在我的Gmail插件中进行处理。我发现以下POST请求in this link

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.*'
  }

0 个答案:

没有答案