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

Getting 400 response for Get Activities List using python

ANSWERED

Hi,

Am trying to read my activity list using the Get Activities List API from python. Other API calls work fine. Below is the request object. I am not sure what am I missing here. I get a 400 bad request exception. 

 

url https://api.fitbit.com/1/user/-/activities/list.json
kwargs {'data': {'afterDate': '2020-11-11', 'sort': 'asc', 'limit': 20, 'offset': 0}, 'client_id': '<myclientid>', 'client_secret': '<mysecretkey>', 'headers': {'Accept-Language': 'en_US'}}
method GET

 

Regards,

Shyam.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @Shyamshiv2k 

 

I'm not familiar with python to confirm your syntax.   Here's a curl example

 

curl -X GET "https://api.fitbit.com/1/user/-/activities/list.json?afterDate=2020-11-11&sort=asc&offset=0&limit=20" -H "accept: application/x-www-form-urlencoded" -H "authorization: Bearer <access token>"

 

Also, you should not be specifying your client ID and client secret when executing the API calls.   Instead, use the access token provided when the user consents to share their data with your application.

 

Gordon

 

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

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

Hello Anyone ?

 

Regards,

Shyam.

Best Answer
0 Votes

Somebody pls help !!!!!! Even if you can point me to any example on github or something for this specific method using python it would be helpful.

Best Answer
0 Votes

Hi @Shyamshiv2k 

 

I'm not familiar with python to confirm your syntax.   Here's a curl example

 

curl -X GET "https://api.fitbit.com/1/user/-/activities/list.json?afterDate=2020-11-11&sort=asc&offset=0&limit=20" -H "accept: application/x-www-form-urlencoded" -H "authorization: Bearer <access token>"

 

Also, you should not be specifying your client ID and client secret when executing the API calls.   Instead, use the access token provided when the user consents to share their data with your application.

 

Gordon

 

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

Thanks GordonFitbit,

I just played around with the parameters in my python code to exactly match the curl command you have given above as example and it worked. Thanks. 

Main thing was the send the parameters as "params" and not as "data" to the requests.get method. Once I changed that it worked.

 

Regards,

Shyam.

Best Answer
0 Votes