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

Cannot get Activity Data from Fitbit Web API

I'm trying to get activity list as shown in https://dev.fitbit.com/build/reference/web-api/explore/#/Activity/getActivitiesLogList using this code:

var userID = '123467' 
var date = '2020-02-12'
var
exerciseXhr = new XMLHttpRequest();
// dates need to be in YYYY-MM-DD format
exerciseXhr.open('GET', 'https://api.fitbit.com/1/user/'+ userID +'/activities/list.json?afterDate='+date+'&sort=asc&offset=0&limit=8');
exerciseXhr.setRequestHeader("Authorization", 'Bearer ' + access_token);
exerciseXhr.onload = function () {
if (exerciseXhr.status === 200) {
console.log(exerciseXhr.responseText);
}
};
exerciseXhr.send();

However, I get a 400 error. Any ideas?

Best Answer
0 Votes
1 REPLY 1

Hi @heartkiIIer,


Welcome to the forums!

 

So that I can investigate, can you provide me with your full HTTP request? I need to be able to see the endpoint, headers, and body of your request to make sure the formatting is correct.

 

Can you also provide me with the error message associated with the error code you're seeing?

Best Answer
0 Votes