Title: TCX endpoint decoding error error · Issue #175 · orcasgit/python-fitbit · GitHub
Open Graph Title: TCX endpoint decoding error error · Issue #175 · orcasgit/python-fitbit
X Title: TCX endpoint decoding error error · Issue #175 · orcasgit/python-fitbit
Description: 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. DE...
Open Graph Description: 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:Invokin...
X Description: 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:Invokin...
Opengraph URL: https://github.com/orcasgit/python-fitbit/issues/175
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TCX endpoint decoding error error","articleBody":"The [Get Activity TCX](https://dev.fitbit.com/build/reference/web-api/activity/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.\r\n\r\nTraceback:\r\n```\r\nDEBUG:requests_oauthlib.oauth2_session:Invoking 0 protected resource request hooks.\r\nDEBUG:requests_oauthlib.oauth2_session:Adding token {'access_token': '********', 'refresh_token': '********''} to request.\r\nDEBUG:requests_oauthlib.oauth2_session:Requesting url https://api.fitbit.com/1/user/-/activities/123456789d.tcx using method GET.\r\nDEBUG:requests_oauthlib.oauth2_session:Supplying headers {'Accept-Language': 'en_US', 'Authorization': 'Bearer ********'} and data {}\r\nDEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'params': {}}.\r\nDEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.fitbit.com:443\r\nDEBUG:urllib3.connectionpool:https://api.fitbit.com:443 \"GET /1/user/-/activities/123456789.tcx HTTP/1.1\" 200 1025205\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\my_username\\Miniconda3\\envs\\fitbit\\Lib\\site-packages\\fitbit\\api.py\", line 266, in make_request\r\n rep = json.loads(response.content.decode('utf8'))\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\my_username\\Miniconda3\\envs\\fitbit\\Lib\\json\\__init__.py\", line 346, in loads\r\n return _default_decoder.decode(s)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\my_username\\Miniconda3\\envs\\fitbit\\Lib\\json\\decoder.py\", line 337, in decode\r\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\my_username\\Miniconda3\\envs\\fitbit\\Lib\\json\\decoder.py\", line 355, in raw_decode\r\n raise JSONDecodeError(\"Expecting value\", s, err.value) from None\r\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\my_username\\fitbit\\scripts\\fitbit\\get_activity.py\", line 143, in \u003cmodule\u003e\r\n main()\r\n File \"C:\\Users\\my_username\\fitbit\\scripts\\fitbit\\get_activity.py\", line 128, in main\r\n data = client.activity_tcx(log_id=55044510633)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\my_username\\fitbit\\scripts\\fitbit\\get_activity.py\", line 84, in get_activity_tcx\r\n return self.make_request(url, params=params)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\my_username\\Miniconda3\\envs\\fitbit\\Lib\\site-packages\\fitbit\\api.py\", line 268, in make_request\r\n raise exceptions.BadResponse\r\nfitbit.exceptions.BadResponse\r\n```\r\n\r\nMy environment:\r\n- Python 3.11\r\n- Windows 10\r\n- `fitbit` version 0.3.1\r\n\r\nThis is the code I'm using to access this endpoint, which I bound as a method to the `fitbit.Fitbit` class.\r\n\r\n```python\r\ndef get_activity_tcx(self, log_id, user_id: str = None, **params):\r\n\t\"\"\"\r\n\tGet Activity TCX\r\n\thttps://dev.fitbit.com/build/reference/web-api/activity/get-activity-tcx/\r\n\t\"\"\"\r\n\tapi, ver, user_id = self._get_common_args(user_id=user_id)\r\n\turl = f\"{api}/{ver}/user/{user_id}/activities/{log_id}.tcx\"\r\n\treturn self.make_request(url, params=params)\r\n\r\ndef get_activity_log_list(self, user_id: str = None, **params):\r\n\t\"\"\"\r\n\tGet Activity Log List\r\n\thttps://dev.fitbit.com/build/reference/web-api/activity/get-activity-log-list/\r\n\r\n\tUsage:\r\n\t\u003e\u003e\u003e client.activity_log_list(afterDate='2023-01-01', offset=0,\r\n\t\u003e\u003e\u003e limit=100, sort='asc')\r\n\t\"\"\"\r\n\tapi, ver, user_id = self._get_common_args(user_id=user_id)\r\n\turl = f\"{api}/{ver}/user/{user_id}/activities/list.json\"\r\n\treturn self.make_request(url, params=params)\r\n```","author":{"url":"https://github.com/Joe-Heffer-Shef","@type":"Person","name":"Joe-Heffer-Shef"},"datePublished":"2023-04-27T12:57:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/175/python-fitbit/issues/175"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ee172f65-5504-b06b-9171-35b6dd7f4487 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE44:346A19:170175:2017BC:69720DE5 |
| html-safe-nonce | 74b938d35cbd2f6bea534689c8e0e38ed0e8f84e1610a80796bdd9b4a897f23d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTQ0OjM0NkExOToxNzAxNzU6MjAxN0JDOjY5NzIwREU1IiwidmlzaXRvcl9pZCI6Ijg4MDA4NDU0NzQwMDk1ODMwNzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2733def903c9edb20b1f0aa0c5107c49f78f303bd0ff1c0fe23f8e1e60272e36 |
| hovercard-subject-tag | issue:1686801109 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/orcasgit/python-fitbit/175/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c454030ad0a7bc431d63c338fc18e5ec596d4358f638becfdcdaf3eda571232f/orcasgit/python-fitbit/issues/175 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c454030ad0a7bc431d63c338fc18e5ec596d4358f638becfdcdaf3eda571232f/orcasgit/python-fitbit/issues/175 |
| og:image:alt | 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:Invokin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Joe-Heffer-Shef |
| hostname | github.com |
| expected-hostname | github.com |
| None | 453de246939b1e04d711e109432e2df10933270413df93b7a8f8f1df8dda7f18 |
| turbo-cache-control | no-preview |
| go-import | github.com/orcasgit/python-fitbit git https://github.com/orcasgit/python-fitbit.git |
| octolytics-dimension-user_id | 9833 |
| octolytics-dimension-user_login | orcasgit |
| octolytics-dimension-repository_id | 3472837 |
| octolytics-dimension-repository_nwo | orcasgit/python-fitbit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3472837 |
| octolytics-dimension-repository_network_root_nwo | orcasgit/python-fitbit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 12756e5bdb9000be815bbf20a1acc7935638e596 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width