从App Engine调用Google Apps脚本作为Web应用程序返回405

时间:2014-12-02 00:04:44

标签: google-app-engine google-apps-script urlfetch

当我尝试调用作为webapp发布的GAPPS脚本时,我遇到了问题。我试图从AppEngine调用此服务。我正在使用JSON Payload对此脚本执行POST方法。 Urlfetch选项设置为遵循重定向,超时为30秒。该脚本是公开的,对匿名用户开放。

在我的本地GAE开发机器上,脚本中的URLFetch响应为200,一切正常。

当我转向生产时,脚本会被执行,但会返回错误和HTML页面。 我在URLFetch上关注了重定向,并且我将截止日期设置为30秒。

状态回复:405

回复文字:  <!DOCTYPE html><html lang="en" ><head><meta name="description" content="Web word processing, presentations and spreadsheets"><link rel="shortcut icon" href="//ssl.gstatic.com/docs/common/drive_favicon1.ico"><title>Google Drive -- Page Not Found</title><link href="//fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet" type="text/css"><style>/* Copyright 2014 Google Inc. All Rights Reserved. */ .goog-inline-block{position:relative;display:-moz-inline-box;display:inline-block}* html .goog-inline-block{display:inline}*:first-child+html .goog-inline-block{display:inline}#drive-logo{color:#91959c;font-family:"Open Sans",Arial,sans-serif;font-size:27px;font-weight:300;position:absolute;text-shadow:0 1px 1px white;white-space:nowrap}#drive-logo img{padding:0 0.4em 0 0;position:relative;top:2px;vertical-align:middle}#drive-logo a{color:#91959c;text-decoration:none}#drive-logo span.goog-inline-block{margin-top:2px;vertical-align:top}</style><style type="text/css">body {background-color: #fff; font-family: Arial,sans-serif; font-size: 13px; margin: 0; padding: 0;}a, a:link, a:visited {color: #112ABB;}</style><style type="text/css">.errorMessage {font-size: 12pt; font-weight: bold; line-height: 150%;}</style></head><body><div style="margin: auto; max-width: 750px;"><div style="margin: 80px 40px 20px 40px; position:relative; "><div style="position: absolute; top: -80px;"><h1 id="drive-logo"><a href="/"><img src="//www.google.com/images/logos/google_logo_41.png" width="116" height="41" alt="Google logo" ><span class="goog-inline-block">Drive</span></a></h1></div><div align="center"><p class="errorMessage" style="padding-top: 50px">Sorry, the file you have requested does not exist.</p><p> Please check the address and try again. </p><div style="background: #F0F6FF; border: 1px solid black; margin-top: 35px; padding: 10px 125px; width: 300px;"><p><strong>Get stuff done with Google Drive</strong></p><p>Apps in Google Drive make it easy to create, store and share online documents, spreadsheets, presentations and more.</p><p>Learn more at <a href="https://drive.google.com/start/apps">drive.google.com/start/apps</a>.</p></div></div></div></div></body></html>

  • 响应标题:Expires = Fri,1990年1月1日00:00:00 GMT
  • 响应头:X-XSS-Protection = 1;模式=块
  • 响应标题:Alternate-Protocol = 443:quic,p = 0.02
  • 响应头:设置Cookie = NID = 67 = KSieONzrWKqWVEt8E4M2rUo_2nooEJ6qrh80LXTppGKYQux2iGFN-BHoqn7r5Yn0F4WaYtTbXDa6y2iAa3FtRBMAn6qf526lmPkZZek7nSQUvCv4wvthsDsL4P11Yx;域= .googleusercontent.com;路径= /;过期=星期二,02君2015 23时39分38秒GMT;仅Http
  • 响应标头:X-Google-Cache-Control = remote-fetch
  • 响应标头:Server = GSE
  • 响应标头:Cache-Control = no-cache,no-store,max-age = 0,must-revalidate
  • 响应标头:Pragma = no-cache
  • 响应标头:X-Content-Type-Options = nosniff
  • 响应标题:X-Frame-Options = SAMEORIGIN
  • 回复标题:日期=星期一,2014年12月1日23:39:38 GMT
  • 响应标头:P3P = CP =&#34;这不是P3P策略!有关详细信息,请参阅http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657。&#34;
  • 响应标题:Allow = HEAD,GET
  • 响应标头:x-chromium-appcache-fallback-override = disallow-fallback
  • 响应标头:Via = HTTP / 1.1 GWA
  • 响应标头:Content-Type = text / html;字符集= UTF-8

有趣的 - 没有那么多 - 是脚本在大多数情况下始终不会,但并非总是或不适用于所有用户。

您可以看到该回复标题显示Allow=HEAD, GET,但我在我的脚本中实现了doPOst

尽管如此,我已经尝试通过重写整个事物以使用GET和参数来解决这个问题,但我遇到了类似的问题!

长话短说:在GAE本地开发服务器上运行完美且状态响应200,部署到GAE时的错误响应和不稳定行为&gt;

1 个答案:

答案 0 :(得分:0)

作为webapp运行时,GAS非常挑剔。有时,将脚本放入Google云端硬盘上的公共文件夹会有所帮助。