Field API: Search Issues by Date Updated

Here is another question I got from my colleagues a few times. Again, this is about issues/search. This time how to filter by the date of update.

Q.  We want to search for all the new or updated issues since a specific date. For example, we want to get all the new or updated issues since the last Friday (07/24/2015). Is there an API call that will allow us to make such request?

A.  You can use

    POST /fieldapi/issues/v1/search

with conditions set as, e.g.,

conditions = ["f--updated_at,geq,\"2015-07-24\""]

In C#, this will be with escape characters:

string conditions = 
    "[\"f--updated_at,geq,\\\"2015-07-24\\\"\"]";

A little caveat is that, if you look at the issue record you obtained, it shows a list items under fields. However, you won’t see “f—updated_at” listed among them. Rather, it is listed as separate created_at parameter. (See the image below). This might make you think that we cannot use the search condition. However, search condition above still works.

For more discussion about the format of search conditions parameter, please refer to this post: “Field API: Filter Issues by Issue Type“.

2015_0728_FieldApiSearchIssuesByDateUpdated.png

Update 1/23/2017: “created_at” and “updated_at” are actually date and time. If you use “eq” (equal),  it won’t hit unless the time also matches. If you include time, for example, like below, it should work:

[“f–created_at,eq,\”2016-01-10 14:42:01 -0500\””]

If you want to filter by a certain day, you will need to use a combination of “geq” and “leq”.

Mikako

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s