diff --git a/CHANGELOG.md b/CHANGELOG.md index f66fc44..0f96548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ nylas-python Changelog Unreleased -------------- * Add support for Scheduler APIs +* Fixed attachment download response handling v6.4.0 ---------------- diff --git a/nylas/handler/http_client.py b/nylas/handler/http_client.py index 5b1d77a..a2a7be2 100644 --- a/nylas/handler/http_client.py +++ b/nylas/handler/http_client.py @@ -45,7 +45,6 @@ def _validate_response(response: Response) -> dict: return json - def _build_query_params(base_url: str, query_params: dict = None) -> str: query_param_parts = [] for key, value in query_params.items(): @@ -109,7 +108,7 @@ def _execute_download_request( query_params=None, stream=False, overrides=None, - ) -> Union[bytes, Response]: + ) -> Union[bytes, Response,dict]: request = self._build_request("GET", path, headers, query_params, overrides) timeout = self.timeout @@ -124,6 +123,9 @@ def _execute_download_request( stream=stream, ) + if not response.ok: + return _validate_response(response) + # If we stream an iterator for streaming the content, otherwise return the entire byte array if stream: return response