arpanghosh8453 / public-fitbit-projects

A script to fetch data from Fitbit servers using their API and store the data in a local influxdb database.
BSD 4-Clause "Original" or "Old" License
323 stars 29 forks source link

Error retrieving data during intialization #4

Closed badi95 closed 1 year ago

badi95 commented 1 year ago

During first run of docker-compose run publicfitbitprojects after entering refresh token getting error:


  File "/app/Fitbit_Fetch.py", line 542, in <module>
    get_intraday_data_limit_1d(date_str, [('heart','HeartRate_Intraday','1sec'),('steps','Steps_Intraday','1min')]) # 2 queries x number of dates ( default 2)
  File "/app/Fitbit_Fetch.py", line 216, in get_intraday_data_limit_1d
    data = request_data_from_fitbit('https://api.fitbit.com/1/user/-/activities/' + measurement[0] + '/date/' + date_str + '/1d/' + measurement[2] + '.json')["activities-" + measurement[0] + "-intraday"]['dataset']
KeyError: 'activities-heart-intraday'```
arpanghosh8453 commented 1 year ago

If Intraday data is not supported by your device, please comment out the following lines containing get_intraday_data_limit_1d ( ) function:

https://imgur.com/njNRz5R

line no 542, 586, 599 in the Fitbit_Fetch.py file to be specific.

badi95 commented 1 year ago

That got me further along once I commented out the for loops on 541 and 585.

Now I'm getting an error:

Maybe doesn't like trying to get 8/28 data when it's still 8/27?


Traceback (most recent call last):
  File "/app/Fitbit_Fetch.py", line 543, in <module>
    get_daily_data_limit_30d(start_date_str, end_date_str) # 3 queries
  File "/app/Fitbit_Fetch.py", line 296, in get_daily_data_limit_30d
    spo2_data_list = request_data_from_fitbit('https://api.fitbit.com/1/user/-/spo2/date/' + start_date_str + '/' + end_date_str + '/all.json')
  File "/app/Fitbit_Fetch.py", line 100, in request_data_from_fitbit
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.fitbit.com/1/user/-/spo2/date/2023-08-27/2023-08-28/all.json```
arpanghosh8453 commented 1 year ago

Yes, your spo2 for that date is not updated yet and hence you get that error.