使用UrlFetchApp.fetch获取错误503 [英] Getting Error 503 with UrlFetchApp.fetch

查看:125
本文介绍了使用UrlFetchApp.fetch获取错误503的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来解决/调试错误,我们现在使用的脚本在2012年12月7日之前可以正常工作.

I need some help resolving/debugging an error we are now getting on a script that was working fine until 2012-12-07.

我们有一个附加到电子表格的Google App脚本(包含多个功能),使我们能够对Google网上论坛设置特定的权限.直到最近,该脚本一直有效.尚未对脚本进行任何代码更改.现在,我们在发生提取操作[resp = UrlFetchApp.fetch(url, options);]

We have a Google App script (comprised of several functions) that is attached to a spreadsheet and enables us to set specific permissions on our Google groups. Until recently this script worked without issue. No code changes have been made to the script. We are now getting error 503 at the point where a fetch occurs [resp = UrlFetchApp.fetch(url, options);]

出于将其发布到此论坛的目的,我已更改了发生错误的功能并对其进行了更改,以便可以独立运行它并生成错误.我已替换了ConsumerKey,ConsumerSecret和其他标识信息.我们非常有信心硬编码值(例如ConsumerKey)仍然有效.

For the purposes of posting it to this forum, I have altered the function where the error occurs and changed it so that it can be run standalone and also generates the error. I have replaced the ConsumerKey, ConsumerSecret, and other identifying information. We are fairly confident that the hard coded values (e.g. ConsumerKey) are still valid.

我们得到的错误是:

对于返回的代码503的请求失败.服务器响应:{错误":{错误":[{域":全局",原因":"backendError",消息":后端错误"} ],代码":503,消息":后端错误"}}(第85行)

Request failed for returned code 503. Server response: { "error": { "errors": [ { "domain": "global", "reason": "backendError", "message": "Backend Error" } ], "code": 503, "message": "Backend Error" } } (line 85)

功能如下:

function updateGroup(){
  groupSettingsUrl = "https://www.googleapis.com/groups/v1/groups/";
  scope = "https://www.googleapis.com/auth/apps.groups.settings";

  oAuthConfig = UrlFetchApp.addOAuthService("Groups");
  oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
  oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
  oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
  oAuthConfig.setConsumerKey("?.apps.googleusercontent.com");
  oAuthConfig.setConsumerSecret("?");

  var options =
    {
      method : "put",
      oAuthServiceName : "Groups",
      oAuthUseToken : "always",
      payload : '{"defaultMessageDenyNotificationText":"","whoCanJoin":"INVITED_CAN_JOIN","kind":"groupsSettings#groups","id":"testadmins@TST.com","customReplyTo":"   ","allowWebPosting":"true","description":"Test Admins. Systems List","name":"Test Admins","membersCanPostAsTheGroup":"false","whoCanPostMessage":"ANYONE_CAN_POST","includeInGlobalAddressList":"true","whoCanViewMembership":"ALL_IN_DOMAIN_CAN_VIEW","allowExternalMembers":true,"allowGoogleCommunication":"false","isArchived":false,"showInGroupDirectory":true,"replyTo":"REPLY_TO_IGNORE","archiveOnly":"false","email":"testadmins@TST.com","whoCanInvite":"ALL_MANAGERS_CAN_INVITE","sendMessageDenyNotification":"false","spamModerationLevel":"MODERATE","whoCanViewGroup":"ALL_MEMBERS_CAN_VIEW","messageDisplayFont":"DEFAULT_FONT","maxMessageBytes":5242880,"messageModerationLevel":"MODERATE_NONE"}',
      contentType: 'application/json'
    };

  url = groupSettingsUrl+"testadmins@TST.com"; 

  var resp;
  resp = UrlFetchApp.fetch(url, options);

  return "Response " + resp.getResponseCode() + "\n body - " + resp.getContentText();
}

推荐答案

很抱歉,我花了很长时间才能回复Arun.我们可以通过GET方法成功使用UrlFetchApp.fetch.

Sorry it's taken so long for me to respond Arun. We are able to successfully use UrlFetchApp.fetch with the method being GET.

这篇关于使用UrlFetchApp.fetch获取错误503的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆