0

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

MushyMiddle
  • 419
  • 6
  • 14
  • Can you trying using this query format? Take note of the quotes. createdTime > '2016-10-10' Since Directory API is close to Drive REST API, it only makes sense that they use the same syntax. If this doesn't work, then maybe it's not supported as the valid keywords are found in [search Users](https://developers.google.com/admin-sdk/directory/v1/guides/search-users). – ReyAnthonyRenacia Nov 23 '16 at 13:07
  • @nogui Thanks for the response. Yes, I did try quoting the timestamp, both as a simple date, and as the format returned in the JSON, and got the same generic error. I may play around with a different object that does have a native (supported) Date field, and work out whether the issue is the query format, or the field (I suspect the field, at this point). – MushyMiddle Nov 23 '16 at 16:44
  • there you have it. Answer says only the fields specified in [users.list](https://developers.google.com/admin-sdk/directory/v1/guides/search-users) are supported where 'creationTime' is not included. – ReyAnthonyRenacia Nov 24 '16 at 01:54

1 Answers1

1

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.

Peter
  • 5,501
  • 2
  • 26
  • 42