05-09-2019 12:22 - edited 05-09-2019 12:23
05-09-2019 12:22 - edited 05-09-2019 12:23
Hello,
I want to fetch the Activity data as shown in https://dev.fitbit.com/build/reference/web-api/activity/
first example.
What I get with that ToFullUrl("/1/user/-/activities/date/{0}.json", ToFitbitFormat(activityDate));
is just the summary even tough I made some Activites like runnning etc. I can see them in the Fitbit App,
how can I get them from the FitbitAPI?
Thanks in advance
Answered! Go to the Best Answer.
05-14-2019 09:01
05-14-2019 09:01
Hi @DeniOcean
The 400 Error in your first API call is correct. The Get Activities List endpoint does have required query parameters that you need to add. Those are beforeDate or afterDate, sort, limit and offset. We have the information documented here: https://dev.fitbit.com/build/reference/web-api/activity/#get-activity-logs-list.
If you return the error message body, we should be providing you with a hint to the error.
I'm not sure if the other 2 examples contain a typo in your code or the forum post, but I see you misspelled "afterDate" as "afterData". Correcting that spelling error allows me to execute the last example successfully, https://api.fitbit.com/1/user/-/activities/list.json?afterData=2019-05-10&sort=desc&offset=3&limit=1...
05-09-2019 16:41
05-09-2019 16:41
Hi @DeniOcean
Manually or tracker recorded activities should appear in the /1/user/-/activities/date/<date>.json endpoint. Auto-detected activities will not appear here. However, you can see all manually, tracker and auto-detected activities in the Get Activities List endpoint, https://api.fitbit.com/1/user/-/activities/list.json
Gordon
05-10-2019 00:41 - edited 05-10-2019 00:42
05-10-2019 00:41 - edited 05-10-2019 00:42
Hello @GordonFitbit
thanks for your reply. So I m calling exatly the url (https://api.fitbit.com/1/user/-/activities/list.json) you showed and I getting a
"The remote server returned an error: (400) Bad Request" back. But with the other command
I ll get an answer but without any activities in.
Thanks
05-13-2019 15:09
05-13-2019 15:09
Hi @DeniOcean
Are you providing any of the query parameters with the API call? They are documented here: https://dev.fitbit.com/build/reference/web-api/activity/#get-activity-logs-list. If so, please provide the complete URL you're executing.
Also, you could try executing the endpoint using the Web API Explorer, https://dev.fitbit.com/build/reference/web-api/explore/. If you get it to work there, copy/paste the URL only to your code.
Gordon
05-14-2019 04:07 - edited 05-14-2019 04:26
05-14-2019 04:07 - edited 05-14-2019 04:26
Hello @GordonFitbit
if I HTTP GET https://api.fitbit.com/1/user/-/activities/list.json?afterDate=2019-05-13
I m getting back a HTTP 400 Error.
the same with :
https://api.fitbit.com/1/user/-/activities/list.json?afterData=2019-05-10&sort=desc&limit=10
same with :
always with that header
request.Method = "GET"; request.Headers["Authorization"] = "Bearer " + accesToken; request.Accept = "application/json";
05-14-2019 09:01
05-14-2019 09:01
Hi @DeniOcean
The 400 Error in your first API call is correct. The Get Activities List endpoint does have required query parameters that you need to add. Those are beforeDate or afterDate, sort, limit and offset. We have the information documented here: https://dev.fitbit.com/build/reference/web-api/activity/#get-activity-logs-list.
If you return the error message body, we should be providing you with a hint to the error.
I'm not sure if the other 2 examples contain a typo in your code or the forum post, but I see you misspelled "afterDate" as "afterData". Correcting that spelling error allows me to execute the last example successfully, https://api.fitbit.com/1/user/-/activities/list.json?afterData=2019-05-10&sort=desc&offset=3&limit=1...
05-14-2019 10:37