POST无法在URLFetchApp中工作

时间:2016-06-27 07:06:13

标签: ruby-on-rails google-apps-script google-sheets

我正在尝试通过UrlFetchApp进行发布呼叫但是当我查看我的服务器日志时,我看到正在进行GET调用。我的代码看起来像这样

var payload ={
"fieldOne" : "value for field one",
"fieldTwo" : "value for field two",
"fileAttachment": "hg"
};
var options =
{
 "method" : "post",
 "payload" : payload
};
UrlFetchApp.fetch("http://**/send_sms/*********", options);

开始GET" / send_sms / ****" for 107.178.194.204 at 2016-06-27 12:27:41 +0530

我的路线文件

中也有帖子

1 个答案:

答案 0 :(得分:0)

也许您的POST标头需要指定Content-Type和Accept属性:

var options =
{
 "method" : "post",
 "Accept" : "you accepted types"
 "Content-Type": "YOUR CONTENT TYPE HERE",
 "payload" : payload
};

Stack Overflow example