[英]Call Google Apps Script API with GmailApp function from Postman [without using AuthO2]
I am trying to access the Google Apps Script Gmail service with Postman .我正在尝试使用Postman访问Google Apps Script Gmail 服务。 Here is my Google Apps Script Code, with a straightforward sendMail function:这是我的 Google Apps 脚本代码,带有一个简单的 sendMail 函数:
function sendMail() {
GmailApp.sendEmail('email@gmail.com','from inTracck','Test for new API source')
}
As you may see, it's a code to send a simple email.如您所见,这是发送简单电子邮件的代码。 After deploying my project in Google Apps Script, I've got a Web App address to use on my postman:在 Google Apps 脚本中部署我的项目后,我有一个 Web 应用程序地址可用于我的邮递员:
Web App Address:
https://script.google.com/macros/s/.../exec
I put it all on my Postman, here is how I use it:我把它全部放在我的邮递员上,这是我的使用方法:
Now, the issue is that when I send the API , it doesn't work.现在,问题是当我发送API时,它不起作用。 I know that I might have to fill out the body section, but since I'm not very technical, I didn't know how to fill that to make the API works and send an email from my Postman.我知道我可能必须填写正文部分,但由于我不是很技术,我不知道如何填写该部分以使 API 工作并从我的邮递员发送电子邮件。
You need a doGet()
function to return data:您需要一个doGet()
函数来返回数据:
function doGet(){
sendMail();// call send email function
return ContentService.createTextOutput('Email Sent!')
}
You should publish it with these configurations:您应该使用以下配置发布它:
Note: Republishing changes the URL.注意:重新发布会更改 URL。 Make sure to use the newly published URL in Postman.确保使用 Postman 中新发布的 URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.