From 1d831ddbfc94eefd1a2362e8ad67630fc5ed72d9 Mon Sep 17 00:00:00 2001 From: ehendrix23 Date: Wed, 6 Nov 2024 16:38:29 -0700 Subject: [PATCH] Fix json attribute error when calling API for a GET with parameters The httpx get method does not support the json parameter, instead the params parameter has to be provided. --- teslajsonpy/connection.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/teslajsonpy/connection.py b/teslajsonpy/connection.py index 45201a03..65339ce5 100644 --- a/teslajsonpy/connection.py +++ b/teslajsonpy/connection.py @@ -200,9 +200,14 @@ async def __open( try: if data: - resp: httpx.Response = await getattr(self.websession, method)( - str(url), json=data, headers=headers, cookies=cookies - ) + if method == "get": + resp: httpx.Response = await getattr(self.websession, method)( + str(url), params=data, headers=headers, cookies=cookies + ) + else: + resp: httpx.Response = await getattr(self.websession, method)( + str(url), json=data, headers=headers, cookies=cookies + ) else: resp: httpx.Response = await getattr(self.websession, method)( str(url), headers=headers, cookies=cookies