I'd like to find if user with certain username exists on my Gmail. So far I tried:
String query = "email='"+username+"@my.domain.com'";
users = directoryService.users().list().setQuery(query).execute();
But I only get:
13:47:12.654 [1651372403@qtp-1044945601-1] ERROR p.e.u.d.g.a.m.SDKGAManagementServiceImpl(153) - com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Bad Request",
"reason" : "badRequest"
} ],
"message" : "Bad Request"
}
I tried to query for a user with known username and I got desired response so I'm certain that the issue lies here. Could someone provide any help?
If you want to find the user using admin sdk, then you should give query like [email protected]. Also, even though its not mentioned in documentation, for users.list,you should give domain name too.
After giving the above parameters, I was able to successfully find the user. Let me know if you have questions.