0

我需要一些帮助来解决/调试我们现在遇到的一个错误,该脚本在 2012 年 12 月 7 日之前运行良好。

我们有一个附加到电子表格的 Google App 脚本(由多个函数组成),使我们能够对我们的 Google 群组设置特定权限。直到最近,这个脚本才能正常工作。没有对脚本进行任何代码更改。我们现在在发生提取时收到错误 503 [ resp = UrlFetchApp.fetch(url, options);]

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

我们得到的错误是:

请求返回代码 503 失败。服务器响应:{“错误”:{“错误”:[{“域”:“全局”,“原因”:“后端错误”,“消息”:“后端错误”}],“代码”:503,“消息”:“后端错误”}}(第 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();
}
4

1 回答 1

1

抱歉,我花了这么长时间才回复 Arun。我们能够通过 GET 方法成功使用 UrlFetchApp.fetch。

于 2013-01-04T20:18:13.813 回答