The Get Activity TCX has a UTF-8 XML response, so it creates an error when called using the API code which seems to expect a JSON response.
Traceback:
DEBUG:requests_oauthlib.oauth2_session:Invoking 0 protected resource request hooks.
DEBUG:requests_oauthlib.oauth2_session:Adding token {'access_token': '********', 'refresh_token': '********''} to request.
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://api.fitbit.com/1/user/-/activities/123456789d.tcx using method GET.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {'Accept-Language': 'en_US', 'Authorization': 'Bearer ********'} and data {}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'params': {}}.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.fitbit.com:443
DEBUG:urllib3.connectionpool:https://api.fitbit.com:443 "GET /1/user/-/activities/123456789.tcx HTTP/1.1" 200 1025205
Traceback (most recent call last):
File "C:\Users\my_username\Miniconda3\envs\fitbit\Lib\site-packages\fitbit\api.py", line 266, in make_request
rep = json.loads(response.content.decode('utf8'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\my_username\Miniconda3\envs\fitbit\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\my_username\Miniconda3\envs\fitbit\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\my_username\Miniconda3\envs\fitbit\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\my_username\fitbit\scripts\fitbit\get_activity.py", line 143, in <module>
main()
File "C:\Users\my_username\fitbit\scripts\fitbit\get_activity.py", line 128, in main
data = client.activity_tcx(log_id=55044510633)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\my_username\fitbit\scripts\fitbit\get_activity.py", line 84, in get_activity_tcx
return self.make_request(url, params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\my_username\Miniconda3\envs\fitbit\Lib\site-packages\fitbit\api.py", line 268, in make_request
raise exceptions.BadResponse
fitbit.exceptions.BadResponse
My environment:
Python 3.11
Windows 10
fitbit version 0.3.1
This is the code I'm using to access this endpoint, which I bound as a method to the fitbit.Fitbit class.
The Get Activity TCX has a UTF-8 XML response, so it creates an error when called using the API code which seems to expect a JSON response.
Traceback:
My environment:
fitbit
version 0.3.1This is the code I'm using to access this endpoint, which I bound as a method to the
fitbit.Fitbit
class.