04-11-2023 12:11
04-11-2023 12:11
Hi, I'm developing an application based on the Fitbit API (I'm the one that created the Go-client for Fitbit).
The first request to the activity logs endpoint works fine, the request is made to the URL:
https://api.fitbit.com/1/user/-/activities/list.json?sort=desc&offset=0&limit=100&beforeDate=DATET20%3A55
The returned pagination.next value contains:
https://api.fitbit.com/1/user/-/activities/list.json?offset=100&limit=100&sort=desc&beforeDate=DATET20%3A56
That's supposed to be the URL to request to fetch the following 100 activities. Anyway, this doesn't work. The server returns every time
StatusCode: 504. Message: Gateway Timeout
The problem is with the offset parameter: if my first request is made to the very same endpoint, with any possible value of offset the server always returns 504.
So, how can I paginate the responses? I guess there's a bug on your side that's preventing this to work as expected.
Waiting for your reply.
Greetings
ps: in the URLs instead of DATE please add the in the format YYYY-mm-dd.
For some reason, the forum is preventing me to post with this error message (I guess this is a bug of this forum):
The message body contains TWENTYTHRRE-ZEROFOUR-ELEVEN , which is not permitted in this community. Please remove this content before sending your post.
I can't use numbers somehow (wtf)
04-13-2023 15:50
04-13-2023 15:50
Hi @pgaleone,
Thanks for reporting this issue. Looking at your endpoint, I immediately noticed that your offset was set to 100. The only value supported for this field is 0, per the documentation. Could you retry your request and let me know if the issue still persists? Thanks!
04-13-2023 22:00
04-13-2023 22:00
Yes, I read the documentation. But the problem is in your API response, that's returning me the pagination.next URL containing the offset=100.
Anyway, I guess I understood the problem: poor (terrible) error reporting.
I can make requests without any problem (even using the returned pagination.next URL) if the limit is a number less than 100. As soon as my request becomes the request of some activity older than the latest 100, the server starts returning 504.
This means that API endpoint is just limited (on Fitbit side, not documented, and for no apparent reason) to return only AT MOST the latest 100 acttivities.
Can you verify this? If it is as I guess, you should update the documentation accordingly (and also returning a meaningful error).
For additionally clarifying:
A request to
works.
A request to
https://api.fitbit.com/1/user/-/activities/list.json?sort=desc&offset=0&limit=101&beforeDate=DATET20%3A55
it doesnt.
If I change the limit to 10, for example
https://api.fitbit.com/1/user/-/activities/list.json?sort=desc&offset=0&limit=10&beforeDate=DATET20%3A55
The API returns this pagination.next value for the next API request:
https://api.fitbit.com/1/user/-/activities/list.json?sort=desc&offset=10&limit=10&beforeDate=DATET20%3A55
and it works without any problem.