googleapis / google-api-python-client

🐍 The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.67k stars 2.39k forks source link

[Admin API] Insert email with + sign into a google group fails #1982

Open kushagra-arta opened 1 year ago

kushagra-arta commented 1 year ago

https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/python/latest/admin_directory_v1.members.html#insert

Environment details

Steps to reproduce

  1. Try to insert any email with a + sign into a group -> 404 Error
  2. Exactly same code with an email without the + sign works -> 200.

Code example

...
service = build('admin', 'directory_v1', credentials=creds)
new_member = {'email': '<any email with + e.g. email+test@gmail.com'>, 'role': 'MEMBER'}
service.members().insert(groupKey=<group_id>, body=new_member).execute()

Stack trace

<HttpError 404 when requesting https://admin.googleapis.com/admin/directory/v1/groups/<group_id>/members?alt=json returned "Resource Not Found: email+test@gmail.com". Details: "[{'message': 'Resource Not Found: email+test@gmail.com', 'domain': 'global', 'reason': 'notFound'}]">

The same email when inserted via UI works.

aria1991 commented 1 year ago

@kushagra-arta Could you please check whether you run into syntax error or not while executing it on your local machine, cause somehow I have this feeling that it might be related to the syntax error. It would be great if you could replace the two last lines with these and check the result:

new_member = {'email': '[test+email@gmail.com](mailto:test+email@gmail.com)', 'role': 'MEMBER'} service.members().insert(groupKey='group123456', body=new_member).execute()