Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the format for the Directory.users().list().setQuery method?

The documentation states:

Query string for prefix matching searches. Should be of the form "key":"value" where key can be "email", "firstName" or "lastName".

I've tried:

directory.users().list().setQuery("email:" + email).execute()

directory.users().list().setQuery("\"email\":\"" + email + "\"").execute()

directory.users().list().setQuery("email:\"" + email + "\"").execute()

They all return a 400 : Bad Request response. How do I properly filter on the email address? Thank you!

like image 713
piusvelte Avatar asked Feb 04 '26 18:02

piusvelte


2 Answers

Currently the list API supports only prefix queries, please refer to the documentation for query parameter here.

Try with query as "email:[email protected]*" -> Note the asterisk at the end.

like image 177
Ajay Guwalani Avatar answered Feb 13 '26 01:02

Ajay Guwalani


Here's the way to get a user by email address.

directory.users().get(userKey=email).execute()

Code to search for a user by email address should be something like

directory.users().list(query='email:[email protected]').execute()

but this doesn't work. I suspect a bug in Google's API docs, or possibly in the actual implementation.

like image 26
SteelPangolin Avatar answered Feb 13 '26 01:02

SteelPangolin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!