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

[亡魂溺海] 提交于 2019-12-07 14:07:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!