From 18f6a6d82fbbc9e2aa18c458567b3fc71486e058 Mon Sep 17 00:00:00 2001 From: Marko Kevac Date: Mon, 16 Sep 2024 17:01:44 +0200 Subject: [PATCH] do not fail if response is not json (e.g. xml) --- vespa/deployment.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vespa/deployment.py b/vespa/deployment.py index 0e59d990..f6505cd9 100644 --- a/vespa/deployment.py +++ b/vespa/deployment.py @@ -1284,7 +1284,10 @@ def _request_with_api_key( response = self.get_connection_response_with_retry(method, path, body, headers) if return_raw_response: return response - parsed = json.load(response) + try: + parsed = json.load(response) + except json.JSONDecodeError: + parsed = response.read() if response.status_code != 200: print(parsed) raise HTTPError(