diff --git a/surepy/client.py b/surepy/client.py index eff2ad3..5d1bde5 100644 --- a/surepy/client.py +++ b/surepy/client.py @@ -166,7 +166,7 @@ async def get_token(self) -> str | None: try: raw_response: aiohttp.ClientResponse = await session.post( - url=AUTH_RESOURCE, data=authentication_data, headers=self._generate_headers() + url=AUTH_RESOURCE, json=authentication_data, headers=self._generate_headers() ) if raw_response.status == HTTPStatus.OK: @@ -216,6 +216,9 @@ async def call( # if data: # logger.debug("🐾 with data: %s", data) + if json and not data: + data = json + if not self._auth_token: self._auth_token = await self.get_token() @@ -237,7 +240,7 @@ async def call( await session.options(resource, headers=headers) response: aiohttp.ClientResponse = await session.request( - method, resource, headers=headers, data=data, json=json + method, resource, headers=headers, json=data ) if response.status == HTTPStatus.OK or response.status == HTTPStatus.CREATED: