访问已部署的webapp中的URL参数

时间:2013-01-29 18:47:01

标签: google-apps-script

我似乎无法在简单的webapp中访问网址参数。从文档中看起来非常简单:

function doGet(e) {
  var foo = (e.parameters.test);
  return ContentService.createTextOutput("Test: " + foo);    
}

但是当我使用“我的最新代码”开发人员链接或部署版本运行webapp时,foo一直以“未定义”的形式返回。

我还注意到,当页面加载URL参数时,我最终会消失。

网址如下:

https://script.googleusercontent.com/a/macros/mysite.com/echo?user_content_key=superlongstring&lib=otherstring&test=helloworld

1 个答案:

答案 0 :(得分:3)

您应该在脚本URL重定向之前添加参数。

所以看起来应该是 -

https://script.google.com/macros/s/longstring/exec?test=helloworld

enter image description here

重定向的URL实际上仅用于输出,并且不可重复使用,并且不会触发任何新处理。

相关问题