diff --git a/whatsapp_api_client_python/API.py b/whatsapp_api_client_python/API.py index d260ce9..815886b 100644 --- a/whatsapp_api_client_python/API.py +++ b/whatsapp_api_client_python/API.py @@ -113,9 +113,12 @@ def raw_request(self, **arguments: Any) -> GreenAPIResponse: def __handle_response(self, response: Response) -> Optional[NoReturn]: status_code = response.status_code if status_code != 200 or self.debug_mode: - data = json.dumps( - json.loads(response.text), ensure_ascii=False, indent=4 - ) + try: + data = json.dumps( + json.loads(response.text), ensure_ascii=False, indent=4 + ) + except json.JSONDecodeError: + data = response.text if status_code != 200: error_message = (