问题
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!
回答1:
Currently the list API supports only prefix queries, please refer to the documentation for query parameter here.
Try with query as "email:someEmail@someDomain.com*" -> Note the asterisk at the end.
回答2:
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:emily@example.com').execute()
but this doesn't work. I suspect a bug in Google's API docs, or possibly in the actual implementation.
回答3:
maybe this will point you in the right direction:
var listReq = service.Users.List();
listReq.Domain = domain;
Users results = listReq.Execute();
来源:https://stackoverflow.com/questions/17178387/what-is-the-format-for-the-directory-users-list-setquery-method