From f38bc0b42640b77bcdef9367e05ea9511e1ab752 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 21 Oct 2020 23:16:56 +0200 Subject: [PATCH] Fix crash on bad response --- pynyaata/connectors/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pynyaata/connectors/core.py b/pynyaata/connectors/core.py index 38d955e..616970d 100644 --- a/pynyaata/connectors/core.py +++ b/pynyaata/connectors/core.py @@ -117,9 +117,10 @@ def curl_content(url, params=None, ajax=False, debug=True): 'postData': '%s' % urlencode(params) if (method == 'post') else '' })) - response = loads(json_response.text) - output = response['solution']['response'] http_code = json_response.status_code + response = loads(json_response.text) + if 'solution' in response: + output = response['solution']['response'] if debug and http_code != 200: getLogger().exception('%s\n\n%s' % (str(e), json_response.text))