我有一个同步脚本,它正在创建新组和上传设置,如下所示:
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)
我的admin_directory
班级和groups_settings
班级使用google.oauth2
图书馆
我有我加载的json,看起来像这样:
{
"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"
}
当我在 API 资源管理器中使用确切的 JSON 时,它可以工作,但是当我通过这个脚本上传时,我得到
<HttpError 400 when requesting https://www.googleapis.com/groups/v1/groups/<group_name>%40<domain>?alt=json returned "Invalid Value">
而且我似乎无法弄清楚它为什么这样做。
有没有其他人遇到过这个问题,如果有,你能找出错误吗?