Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting Activities Properly

ANSWERED

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

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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...

 

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
0 Votes
6 REPLIES 6

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

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

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 

Best Answer
0 Votes

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

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

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 :

https://api.fitbit.com/1/user/-/activities/list.json?afterData=2019-05-10&sort=desc&offset=3&limit=1...

 

always with that header

            request.Method = "GET";
            request.Headers["Authorization"] = "Bearer " + accesToken;
            request.Accept = "application/json";
Best Answer
0 Votes

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...

 

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Thank you so much @GordonFitbit 

 

"afterDatawas the mistake 😉

 

Shame on me Smiley LOL

Best Answer
0 Votes