简体   繁体   English

doPost(e)Google脚本

[英]doPost(e) google script

I'm currently working with Google Script and I have a problem with doPost(e) , every time I send a POST request to the script I keep getting undefined the variable e 我目前正在使用Google脚本,而doPost(e)则有问题,每次我向脚本发送POST请求时,我都会不断得到未定义的变量e

My code: 我的代码:

function doPost(e){
  var company = JSON.parse(e.postData.contents)['meta']['company_id'];
  var s = SpreadsheetApp.openById('1lEp4Ul0D3eGsIEbjS6rFhjVVVjH6v5ZJvxRfGr5WLWQ');
  var ss = s.getSheetByName('Hoja 1');
  var token = 'hidden secret token';
  // get previous and current data from post
  var previous = JSON.parse(e.postData.contents)['previous'];
  //set the previous stage id to current object
  current['previous_stage_id'] = previous['stage_id'];}

the post responses are all raw body. 帖子的回复全是原始的。

If this information is supposed to cause something to happen on the script side of things you need to add a 如果此信息应该导致脚本方面发生某些事情,则需要添加一个

google.script.run.functionName(responseValues)

to the HTML. 到HTML。 If the HTML needs to get values back add a handler. 如果HTML需要返回值,则添加一个处理程序。

google.script.run.withSuccessHandler(doSomething).functionName()

The doSomething is JS on the page and the functionName is a google script function. doSomething是页面上的JS,而functionName是Google脚本函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Apps脚本(未找到错误脚本功能doPost) - Google apps script(Error script function not found doPost ) Google Apps 脚本 - 避免 doPost 同时执行限制 - Google Apps Script - Avoiding doPost Simultaneous Execution Limits 如何让 Google Apps 脚本 doPost() 读取我的 POST 请求? - How to get Google Apps Script doPost() to read my POST request? Google Script doPost 仅从单个 URL 接受 - Google Script doPost accept from a single URL only Google Apps 脚本:无法将 URL 参数从 doGet() 传递到 doPost() - Google Apps Script: Trouble Passing URL Params from doGet() to doPost() doPost(e)不会触发onChange(e) - Google电子表格中的触发更改事件 - doPost(e) does not trigger onChange(e) - Trigger On Change event in Google Spreadsheet 在 Google Apps 脚本中,如何通过重新加载 doPost() 返回的 HTML 来防止多次提交表单数据? - In Google Apps Script, How to prevent multiple submission of form data by reloading the HTML returned by doPost()? 如何通过POST(doPost)将文件上传到Google Script的Web App? - How to upload a file via POST (doPost) to a Google Script's Web App? Google Apps Script onFormSubmit(e)“e 未定义”? - Google Apps Script onFormSubmit(e) "e is undefined"? 使用doPost方法将e.parameter传递给数组 - Pass e.parameter to array with doPost method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM