GET /v2/timeslips filtering by date_from and date_to produces inconsistent results

Hi,

I want to retrieve the timeslips for a user for a specific day. I’m using the from_date and to_date query params to filter the results. However, it is behaving strangely. For example this request:

GET https://api.sandbox.freeagent.com/v2/timeslips?user=https://api.sandbox.freeagent.com/v2/users/{id}?from_date=2024-06-11&to_date=2024-06-11

Returns two timeslips:

<?xml version="1.0" encoding="UTF-8"?>
<freeagent>
  <timeslips type="array">
    <timeslip>
      ...
      <dated-on type="date">2024-06-11</dated-on>
      ...
    </timeslip>
    <timeslip>
      ...
      <dated-on type="date">2024-06-10</dated-on>
      ...
    </timeslip>
  </timeslips>
</freeagent>

I find it strange the entry from the 06-10 is there, and the 06-10 entry is the only entry if I change the URL to:

GET https://api.sandbox.freeagent.com/v2/timeslips?user=https://api.sandbox.freeagent.com/v2/users/{id}?from_date=2024-06-10&to_date=2024-06-10
<?xml version="1.0" encoding="UTF-8"?>
<freeagent>
  <timeslips type="array">
    <timeslip>
      ...
      <dated-on type="date">2024-06-10</dated-on>
      ...
    </timeslip>
  </timeslips>
</freeagent>

However, when the URL is:

GET https://api.sandbox.freeagent.com/v2/timeslips?user=https://api.sandbox.freeagent.com/v2/users/{id}?from_date=2024-06-09&to_date=2024-06-09

the response correctly contains no entries:

<?xml version="1.0" encoding="UTF-8"?>
<freeagent>
  <timeslips type="array"/>
</freeagent>

Note, the day when I was running these queries was 06-11 which may be affecting results for the first query in this case.

Does anyone know why the entry from 06-10 is included when the filter dates are 06-11?

Thanks,
Dam

Hi there, I’m one of the engineers at FreeAgent, let me look into this for you and I’ll get back to you.

Thanks George. I’ve tested again today and am seeing the same results. I’ve included the created-at and updated-at values in case they are helpful.

GET https://api.sandbox.freeagent.com/v2/timeslips?user=https://api.sandbox.freeagent.com/v2/users/{{id}}?from_date=2024-06-11&to_date=2024-06-11

<?xml version="1.0" encoding="UTF-8"?>
<freeagent>
  <timeslips type="array">
    <timeslip>
      ...
      <dated-on type="date">2024-06-10</dated-on>
      ...
      <updated-at type="dateTime">2024-06-10T21:41:25Z</updated-at>
      <created-at type="dateTime">2024-06-10T21:41:25Z</created-at>
    </timeslip>
    <timeslip>
      ...
      <dated-on type="date">2024-06-10</dated-on>
      ...
      <updated-at type="dateTime">2024-06-10T09:16:40Z</updated-at>
      <created-at type="dateTime">2024-06-10T09:16:40Z</created-at>
    </timeslip>
  </timeslips>
</freeagent>

In the last response timeslips for June 10th are returned even though the filtering should limit to June 11th. I subsequently made a request for the same operation with a different user id and got timeslips from two days, one for the 11th and two for the 10th.

https://api.sandbox.freeagent.com/v2/timeslips?user=https://api.sandbox.freeagent.com/v2/users/{{id}}?from_date=2024-06-11&to_date=2024-06-11

<?xml version="1.0" encoding="UTF-8"?>
<freeagent>
  <timeslips type="array">
    <timeslip>
      ...
      <dated-on type="date">2024-06-11</dated-on>
      ...
      <updated-at type="dateTime">2024-06-11T08:58:53Z</updated-at>
      <created-at type="dateTime">2024-06-11T08:58:53Z</created-at>
    </timeslip>
    <timeslip>
      ...
      <dated-on type="date">2024-06-10</dated-on>
      ...
      <updated-at type="dateTime">2024-06-11T11:16:07Z</updated-at>
      <created-at type="dateTime">2024-06-11T11:16:07Z</created-at>
    </timeslip>
    <timeslip>
      ...
      <dated-on type="date">2024-06-10</dated-on>
      ...
      <updated-at type="dateTime">2024-06-10T09:44:18Z</updated-at>
      <created-at type="dateTime">2024-06-10T09:44:18Z</created-at>
    </timeslip>
  </timeslips>
</freeagent>

Hi George, have you had a chance to look into this?

Hi there Dam,

Thanks for sharing this - I’m just looking in to this alongside George to help pin down what’s happening for you. In order for us to rule out some potential issues, could you share the company and user IDs which you’re using with the sandbox queries with us please?

I’d also like to rule out any potential timezone difference shenanigans; can you confirm which timezone you’re in?

Thanks

Wil - FreeAgent

Hi Will,

Company ID: 18109.

User IDs:

  • 20731
  • 27017

Timezone: GMT+01:00

Thanks

1 Like

Hello Dam,

I’ve looked into these API requests a little and I think what’s happening is it’s being parsed in a way that’s slightly different to your intentions

Currently your query is:

GET https://api.sandbox.freeagent.com/v2/timeslips?user=https://api.sandbox.freeagent.com/v2/users/{id}?from_date=2024-06-11&to_date=2024-06-11

And it seems the API is handling this as user = https://api.sandbox.freeagent.com/v2/users/{id}?from_date=2024-06-11
and then to_date=2024-06-11

Could you try making the request with the user_id and from_date separated by an & rather than by a ?, I believe that should result in all three being handled as separate parameters.

I hope this resolves your issue, please let me know either way.

Thanks

Wil - Freeagent

1 Like

Thanks Wil, in the wise words of one Homer Jay Simpson “Doh!”

Sorry to have taken your time on this. I went URL param blind. Of course when I change it to & it works as expected. Not to self, always leave the user param to last.

It’s so easy to do, don’t worry about it! I’m glad I could help :smiley: