Http Error 500 : backend error

55 views
Skip to first unread message

Ogheneruona Dibie

unread,
Jul 16, 2015, 11:46:42 AM7/16/15
to google-api-p...@googlegroups.com
I have a code that is supposed to perform a batch request to get a setting to a host of groups on my domain and then update the setting using the batch call back to check to see if the group setting is already up to date. I can't tell particularly but at random times, it work , at other time I get the following errors:

HttpError: <HttpError 500 when requesting https://www.googleapis.com/groups/v1/groups/yoreh%40umext.maine.edu?alt=json returned "Backend Error">


Also attached is a snippet of my code:


def insert_group(request_id,response,exception):

 53     global global_count

 54     global batch_update

 55     global group

 56     

 57     body= {'whoCanPostMessage':'ANYONE_CAN_POST',

 58           'showInGroupDirectory':'true'

 59     } 

 60     updated = True;

 61     if exception is not None:

 62         print(traceback.format_exc())

 63     else:

 64         sigd=response['showInGroupDirectory']

 65         wcpm=response['whoCanPostMessage']

 66         

 67         if (sigd !='true' or wcpm !='ANYONE_CAN_POST'):

 68             global_count = global_count + 1;

 69             batch_update.add(group.patch(groupUniqueId = response['email'], body = body));

 70         

 71 def main():

 72     """Gets a list of groups in a googleapp and using it's email, each group setting is 

 73         updated.

 74     """

 75     

 76     global batch_update 

 77     batch_update = BatchHttpRequest()

 78     global global_count

 79     global_count = 0 

 80 

 81     credentials = get_credentials()

 82     http = credentials.authorize(httplib2.Http())

 83     

 84     

 85     # Service used in getting groups

 86     service = discovery.build('admin', 'directory_v1', http=http)

 87     

 88     #Service that is used in updating settings

 89     service1 = discovery.build('groupssettings', 'v1',http=http);

 90     

 91     batch = BatchHttpRequest(callback=insert_group)

 92     count = 0#keep track of the number of settings updated

 93     updated = False

 94     

 95     global group 

 96     group = service1.groups()

 97     

 98     #What to update in the group settings

 99 

100      

101     # get all groups in the umext.maine.edu domain, max set to 500(probably not that much ever)

102     results = service.groups().list(customer='my_customer',domain='umext.maine.edu').execute()

103     groups = results.get('groups', [])

104     if not groups:

105     print 'No groups in the domain.'

106     else:

107     print 'Updating group settings:'

108     print "Creating Batch Script to write a single request to effect all changes\n"

109     for g in groups:

110         batch.add(group.get(groupUniqueId = g['email']))

111         count = count + 1;

112     print("Executing batch request now\n");

113         

114 #   print "{} groups where updated ": {count}

115     batch.execute(http=http)

116     if (global_count > 0):

117         batch_update.execute(http=http);

118             

119     print ("\nThere are {n} amount of grount in umext.maine.edu domain".format(n=count));

120     print ("{x} number of groups were updated".format(x=global_count));

121     print "Done !! Ending Program\n"

122 

123 if __name__ == '__main__':

124     main()

Reply all
Reply to author
Forward
0 new messages