使用UrlFetchApp.fetch获取错误503

时间:2012-12-18 23:42:33

标签: google-apps-script

我需要一些帮助来解决/调试我们现在得到的错误,该错误在2012-12-07之前正常运行。

我们有一个附加到电子表格的Google App脚本(由多个功能组成),使我们能够为我们的Google群组设置特定权限。直到最近,这个脚本没有问题。没有对脚本进行任何代码更改。我们现在在获取[resp = UrlFetchApp.fetch(url, options);]

时获取错误503

为了将其发布到此论坛,我更改了发生错误的功能并更改了它,以便它可以独立运行并生成错误。我已经替换了ConsumerKey,ConsumerSecret和其他识别信息。我们相当确信硬编码值(例如ConsumerKey)仍然有效。

我们得到的错误是:

  

请求失败返回代码503.服务器响应:{“error”:{“errors”:[{“domain”:“global”,“reason”:“backendError”,“message”:“Backend Error”} ],“code”:503,“message”:“Backend Error”}}(第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();
}

1 个答案:

答案 0 :(得分:1)

对不起,我花了很长时间才回应阿伦。我们能够成功使用UrlFetchApp.fetch,方法是GET。