Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change displayName of users in batch query throws an Exception #835

Open
wolfgang-302 opened this issue Mar 4, 2024 · 1 comment
Open
Labels

Comments

@wolfgang-302
Copy link

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.

@wolfgang-302
Copy link
Author

I updated to the newest version of Office365-python-rest-client (2.5.6). The same error occoured in (2.5.4)

@vgrem vgrem added the bug label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants