Rest API with multiple Filters

Using PHP to get data via the REST API and struggling a bit with the filters. I want to get the Time Logs for a specific user on a specific date. Getting them by user was pretty straight forward

&filter[task_assignees.HumanUser.login]=username

However, adding to include a specific date has been troublesome.

&filters[["user.HumanUser.login", "is", "username"],["date", "is, "2019-10-09"]]
That gets me nothing. Multiple filters just isn’t clear to me.

Using cURL and GET

2 Likes

Apparently,
&filter[user.HumanUser.login]=username&filter[date]=actualdate

Seems to be the answer. Please correct if this is wrong.

3 Likes

Hey Chad – welcome to the forums!

I’m glad you were able to find a solution here. What you’re doing works, but it’s limited: your syntax works because the relation between your two filters is an and one, and you are filtering on two different fields. If you wanted to do a query with an or or some other relation between filters, or if you for example, wanted to find a date between two values with queries like “date > foo” and “date < bar”, then stringing together filters with & as you did wouldn’t work.

In order to support more complex cases, you’ll want to use the _search endpoint as documented here.

Hope that helps! Let us know if you have any other questions.

4 Likes

I was unable to get the search to work. As it happens, I have a question specific to getting timelogs between 2 dates in another thread.

I will attempt using search again and post any further queries or findings there.

Thank you for better explanation.

3 Likes