0

I have a sync script which is creating new groups and uploading settings, like so:

        for group in self.groups:
            try:
                print("%s@%s" % (group, self.admin_directory.__domain__))
                self.admin_directory.insert_group(email="%s@%s" % (group, self.admin_directory.__domain__),
                                                  name=group,
                                                  description=group)
                time.sleep(1)
            except HttpError as e:
                if(e.resp.status == 409):
                    print("%s was already a group in Google." % group)
                else:
                    print(e)

            try:
                print(json.dumps(self.groups[group]['settings'], indent=4))
                self.groups_settings.update("%s@%s" % (group, self.admin_directory.__domain__),
                                            self.groups[group]['settings'])
                time.sleep(1)
            except HttpError as e:
                print(e)

My admin_directory class and groups_settings class use the google.oauth2 library

I have json which I load that looks like so:

{
  "kind": "groupsSettings#groups",
  "email": "<email>",
  "name": "<group_name>",
  "description": "<group_name>",
  "whoCanJoin": "INVITED_CAN_JOIN",
  "whoCanViewMembership": "ALL_MEMBERS_CAN_VIEW",
  "whoCanViewGroup": "ALL_MEMBERS_CAN_VIEW",
  "whoCanInvite": "NONE_CAN_INVITE",
  "whoCanAdd": "ALL_MANAGERS_CAN_ADD",
  "allowExternalMembers": "true",
  "whoCanPostMessage": "ALL_IN_DOMAIN_CAN_POST",
  "allowWebPosting": "false",
  "primaryLanguage": "en",
  "maxMessageBytes": 10485760,
  "isArchived": "true",
  "archiveOnly": "false",
  "messageModerationLevel": "MODERATE_ALL_MESSAGES",
  "spamModerationLevel": "REJECT",
  "replyTo": "REPLY_TO_SENDER",
  "customReplyTo": "",
  "includeCustomFooter": "false",
  "customFooterText": "",
  "sendMessageDenyNotification": "false",
  "defaultMessageDenyNotificationText": "",
  "showInGroupDirectory": "false",
  "allowGoogleCommunication": "false",
  "membersCanPostAsTheGroup": "false",
  "messageDisplayFont": "DEFAULT_FONT",
  "includeInGlobalAddressList": "true",
  "whoCanLeaveGroup": "ALL_MEMBERS_CAN_LEAVE",
  "whoCanContactOwner": "ALL_IN_DOMAIN_CAN_CONTACT",
  "whoCanAddReferences": "NONE",
  "whoCanAssignTopics": "NONE",
  "whoCanUnassignTopic": "NONE",
  "whoCanTakeTopics": "NONE",
  "whoCanMarkDuplicate": "NONE",
  "whoCanMarkNoResponseNeeded": "NONE",
  "whoCanMarkFavoriteReplyOnAnyTopic": "NONE",
  "whoCanMarkFavoriteReplyOnOwnTopic": "NONE",
  "whoCanUnmarkFavoriteReplyOnAnyTopic": "NONE",
  "whoCanEnterFreeFormTags": "NONE",
  "whoCanModifyTagsAndCategories": "NONE",
  "favoriteRepliesOnTop": "false"
}

When I use the exact JSON here in the API explorer, it works, but when I upload via this script, I get <HttpError 400 when requesting https://www.googleapis.com/groups/v1/groups/<group_name>%40<domain>?alt=json returned "Invalid Value">

and I cannot seem to figure out why it is doing this.

Has anyone else experienced this issue and if so, were you able to figure out the error?

Avir94
  • 899
  • 9
  • 19
  • Your URL has a URL-encoded `@` in it (note the `%40`) before the query string begins. Maybe your URL does not have the correct structure. – chillin Sep 05 '18 at 19:45
  • You may also need to specify additional headers like `Content-Type: application/json` or `application/x-www-form-urlencoded`, depending on how you're sending this JSON. Try using Developer/Network tools to see what request headers are being sent by the API explorer. – chillin Sep 05 '18 at 19:50
  • I don't need to specify any headers because I use Google's python package to execute these commands. I know the package works because the settings get updated on a test domain. The groups do get created in the production domain, but the group settings return this invalid value error. – Avir94 Sep 05 '18 at 23:23

0 Answers0