Search code examples
google-admin-sdkgoogle-directory-api

Can creationTime and other Directory meta-fields be used in a query?


I'm trying to filter the list of users returned from Directory.Users.List, and want to use the creationTime value in the filter. According to this:

Search for users

...you can use Date fields in comparisons, however when I try something like:

creationTime>=2016-06-30 (or the same value quoted)

...I get:

Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid Input: creationTime>=2016-06-30",
    "reason" : "invalid"
  } ],
  "message" : "Invalid Input: creationTime>=2016-06-30"
}

The message isn't particularly helpful - is this a syntax issue with the query, or is it the case that the field isn't available for query (it isn't listed in that article, but it is part of the JSON response)?

The article specifies the format for Date field queries, however this field also includes a time component, so I tried to also replicate the exact format that shows in the JSON, with the same result.

Also, same result in the Try it! section of the Users reference page.

Also also, tried using a numeric value (Date.getTime(), in effect) - same error.

Thanks...

P.S. Interestingly, Google does document how to search on date fields for Chromebooks, and it's entirely different than they imply for users. I still can't use creationTime with this, but it does work for Chromebooks. The other part of this is that it refers to fields that aren't documented, and why I try to use the documented field (e.g. lastSync vs. sync), it fails with the same message. This whole thing seems half-baked.

View Chrome device information


Solution

  • Only the fields listed in the table are searchable via the users.list search.

    A workaround (I don't know if this is suitable for you) may be to push the data you want to use in a search into custom user fields. These fields are searchable.