Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
Change displayName of users in batch query throws an Exception
I have a list of users where i have to change the displayName. Doing this user by user works. I tried to do this using a batch-query like this.
app_client
is of type office365.graph_client.GraphClient
users_tkl31
is a list of 28 users found by
users_tkl31 = app_client.users.select(cols).filter("department eq 'tkl31'").get().execute_query()
with some given cols.
displaynames
is a list of 28 displaynames found by
trans = {ord(';'):','}
displaynames = [u.properties['displayName'].translate(trans) for u in users_tkl31]
The batch-query ist defined by
for u,n in zip(users_tkl31,displaynames):
print(u,n,end='\n')
u.set_property('displayName',n).update()
app_client.execute_batch(items_per_batch=28)
This leads to the error message
ClientRequestException: ('BadRequest', 'Number of requests inside batch exceed the limit.', '400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/$batch')
This is strange, because the length of users_tkl31
and displaynames
is 28 and this is given in app_client.execute_batch(items_per_batch=28)
as parameter and 28 is smaller then 100.
I tried to change the size of items_per_batch to 7. Then i get another error:
ClientRequestException: ('BadRequest', 'Write request id : 0 does not contain Content-Type header or body.', '400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/$batch')
Maybe i missunderstand the concept of batch-query but i think this should work.
I updated to the newest version of Office365-python-rest-client (2.5.6). The same error occoured in (2.5.4)