Page 1 of 1

JSON API filter by date

Posted: Wed Jul 05, 2017 8:01 am
by bfang
I am attempting to list a series of punches for a given user on a given day using the JSON API, and the "APIPunch" class, "getPunch" method. I am able to filter the results successfully using filter_data;{user_id:'XXXX'}, but all attempts at filtering the results by either "date_stamp" or "punch_date" return all punches, for all days. I have attempted many varieties of date formatting, including a straight Unix timestamp, with no luck. Is there a way to filter punch data by punch date?

Re: JSON API filter by date

Posted: Wed Jul 05, 2017 9:04 am
by shaunw
Try adding this to your filter data:

Code: Select all

'start_date': $start_epoch_value, 'end_date': $end_epoch_value

Re: JSON API filter by date

Posted: Wed Jul 05, 2017 9:16 am
by bfang
I have added start_date and end_date, and still receive all records. My JSON filter looks like this:

[{"filter_data":{"user_id":"676","start_date":1499212800,"end_date":1499212800}]

When I include the dates, it returns every punch, for every person. If I remove the dates my JSON filter looks like:

[{"filter_data":{"user_id":"676"}]

And this returns only punches for user 676.

Re: JSON API filter by date

Posted: Wed Jul 05, 2017 9:26 am
by shaunw
You will need to provide us with more complete code/request samples then, because adding additional parameters shouldn't cause others to be ignored unless there is a bigger problem going on somewhere.

Re: JSON API filter by date

Posted: Wed Jul 05, 2017 9:44 am
by bfang
Thank you. I found the issue. I was missing a } at the end of the filter_data json.