doPost(e)不返回参数但是doGet(e)呢?

Mow*_*zer 1 parameters google-apps-script

在互联网上没有任何地方是这个特定的问题或它提到的修复,所以这里是:

我的应用程序包含以下doGet()doPost()功能:

function doGet (e){return ContentService.createTextOutput("User says: "+JSON.stringify(e))}
function doPost(e){return ContentService.createTextOutput("User says: "+JSON.stringify(e))}
Run Code Online (Sandbox Code Playgroud)

GET http://*published URL*/+params 收益:

User says:     
{
  "queryString":"testparamA=abc&testparamB=bcd&testparamC=cde",
  "parameter":
    {
      "testparamA":"abc",
      "testparamB":"bcd",
      "testparamC":"cde"
    },
  "contextPath":"",
  "parameters":
    {
      "testparamA":["abc"],
      "testparamB":["bcd"],
      "testparamC":["cde"]
    },
  "contentLength":-1
}
Run Code Online (Sandbox Code Playgroud)

然而,POST http://*published URL*/+params回报:

User says:
{
  "queryString":null,
  "parameter":{},
  "contextPath":"",
  "parameters":{},
  "contentLength":0
}
Run Code Online (Sandbox Code Playgroud)

我的目标是访问POST参数.但似乎阻止脚本在使用该POST方法传输时获取它们.GET似乎工作得很好.

我错过了什么,解决方案是什么?

Aru*_*jan 5

使用您发布的完全相同的代码,POST和GET对我来说非常合适.我的猜测是你没有正确测试POST.

这是我发布的网址.后面的代码是您的样本的复制/粘贴 -

https://script.google.com/macros/s/AKfycbzWZv9WUp7rUtOxZhhwuXPpuNXuvPGpiHyrcYrPeNLiusOWzazo/exec

http://hurl.it(浏览器中的简单REST测试器)进行测试,并且没有任何问题.

请求(确保检查以下重定向) -

请求截图

响应(为GET和POST重定向一次ContentService URL后的响应)

响应截图