UW-Madison Google Workspace - Google Groups API - Issues Managing Specific Users
Description
Some email address values that are successfully added to Google Groups may return an error when attempting to manage that user. For example, when attempting to modify the user's "role" or "delivery_settings" within the group will fail with a 404 "Not Found" error, even though the user is a verifiable member of the group.
Workaround
When a specific user is exhibiting this behavior, find the "id" value for that user within the group and use the "id" value rather than "email" for requests to modify the user. Note: the "id" may be unique to a specific group -- always obtain the "id" before making modifications.
When PUT (update) fails identifying a user by "email" with 404 error:
PUT https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members/baduser@domain.com
Get the group's members and find the user's numerical "id":
GET https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members
Run the PUT (update) with the numerical user "id":
PUT https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members/100123456789012345605
Problem Demo
These examples below demonstrate the problem you may encounter with some specific user email addresses.
Adding the member -- member will be problematic to manage:
curl --request POST --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members --header 'Authorization: Bearer sometoken' --data '{"email": "baduser@domain.com", "role": "MEMBER"}
Getting group members -- verifies add member succeeded:
curl --request GET --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members --header 'Authorization: Bearer sometoken'
{ "etag" : "\"some-etag"", "kind" : "admin#directory#members", "members" : [ { "email" : "baduser@domain.com", "etag" : "\"some-etag\"", "id" : "100123456789012345605", "kind" : "admin#directory#member", "role" : "MEMBER", "type" : "USER" } ]}
Modify the member "role" -- fails with "Not Found" error:
curl --request PUT --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members/baduser@domain.com --header 'Authorization: Bearer sometoken' --data '{"role": "MANAGER"}'
{ "error" : { "code" : 404, "errors" : [ { "domain" : "global", "message" : "Resource Not Found: email", "reason" : "notFound" } ], "message" : "Resource Not Found: email" }}
Modify the member "delivery_settings" -- fails with "Not Found" error:
curl --request PUT --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members/baduser@domain.com --header 'Authorization: Bearer sometoken' --data '{"delivery_settings": "DIGEST"}'
{ "error" : { "code" : 404, "errors" : [ { "domain" : "global", "message" : "Resource Not Found: email", "reason" : "notFound" } ], "message" : "Resource Not Found: email" }}
Workaround Demo
Get the list of the group's members -- find the problematic user's "id":
curl --request GET --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members --header 'Authorization: Bearer sometoken'
{ "etag" : "\"some-etag\"", "kind" : "admin#directory#members", "members" : [ { "email" : "baduser@domain.com", "etag" : "\"some-etag\"", "id" : "100123456789012345605", "kind" : "admin#directory#member", "role" : "MEMBER", "type" : "USER" } ]}
Modify the user's "role" using "id" as the user's identifier -- succeeds:
curl --request PUT --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members/100123456789012345605--header 'Authorization: Bearer sometoken' --data '{"role": "MANAGER"}'
{ "delivery_settings" : "ALL_MAIL", "email" : "badyser@domain.com", "etag" : "\"some-etag\"", "id" : "100123456789012345605", "kind" : "admin#directory#member", "role" : "MANAGER", "status" : "ACTIVE", "type" : "USER"}
Modify the user's "delivery_settings" using "id" as the user's identifier -- succeeds:
curl --request PUT --url https://api.wisc.edu/ggroups/admin/directory/v1/groups/example@g-groups.wisc.edu/members/100123456789012345605--header 'Authorization: Bearer sometoken' --data '{"delivery_settings": "DIGEST"}'
{ "delivery_settings" : "DIGEST", "email" : "baduser@domain.com", "etag" : "\"some-etag\"", "id" : "100123456789012345605", "kind" : "admin#directory#member", "role" : "MANAGER", "status" : "ACTIVE", "type" : "USER"}
