Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json Google应用程序脚本-脚本已完成,但未返回任何内容,新行未插入_Json_Google Apps Script_Postman - Fatal编程技术网

Json Google应用程序脚本-脚本已完成,但未返回任何内容,新行未插入

Json Google应用程序脚本-脚本已完成,但未返回任何内容,新行未插入,json,google-apps-script,postman,Json,Google Apps Script,Postman,我正试图通过谷歌应用程序脚本在谷歌电子表格中插入新行。 我得到了同样的错误-“脚本已完成,但没有返回任何内容。” 不插入新行 我试过很多youtube教程 我的应用程序脚本文件 var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1m6KuS2Pk4_aL4LcNanWtApE4nFWxwJ4-vokETe-qfao/edit#gid=0"); var sheet = ss.get

我正试图通过谷歌应用程序脚本在谷歌电子表格中插入新行。 我得到了同样的错误-“脚本已完成,但没有返回任何内容。” 不插入新行

我试过很多youtube教程

我的应用程序脚本文件

var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1m6KuS2Pk4_aL4LcNanWtApE4nFWxwJ4-vokETe-qfao/edit#gid=0");
var sheet = ss.getSheetByName("Items");
   
function doPost(e){
  var action = e.parameter.action;
  if(action == "Id"){
    return addItem(e);
  }   
}
   
function addItem(e){
  var date =  new Date();
  var Id = e.parameter.Id;
  sheet.appendRow([date,Id]);
  return ContentService.createTextOutput("Success").setMimeType(ContentService.MimeType.TEXT);   
}
因此不会添加新行。 当打电话给邮递员时,显示的是相同的信息

“脚本已完成,但未返回任何内容。”

邮递员的链接是

json中的主体是 {“action”:“Id”,“Id”:“Id1”}

试试这个:

function doGet(e){
  var action = e.parameter.action;
  if(action=="Id"){
    var ss=SpreadsheetApp.getActive();//you can open your spreadsheet however you wish but I find this easier if your web app is contained
    var sh=ss.getSheetByName("Items");
    var date= new Date();
    sh.appendRow([date,action]);
    return ContentService.createTextOutput("Success").setMimeType(ContentService.MimeType.TEXT);
  }
}

将此代码放入doPost并将一些值记录到工作表中以进行调试:
function doPost(e){var payloadType,isActionID;var action=e.parameter.action;payloadType=action=='string'?'payloadis string':'payloadis not string';isActionID=action='Id'?'Passed Test':'FAILED!';sheet.appendRow([payloadType,isActionID]);如果(action==“Id”){return addItem(e);}
运行下一个函数是否通过了测试?