diff --git a/cieloApi3/request/base.py b/cieloApi3/request/base.py index 3b8cd4d..763e005 100644 --- a/cieloApi3/request/base.py +++ b/cieloApi3/request/base.py @@ -36,7 +36,13 @@ def send_request(self, method, uri, data=None, params=None): response = s.send(prep) - if 'json' in response.headers['Content-Type'].lower(): + try: + is_json = 'json' in response.headers['Content-Type'].lower() + except KeyError: + # Content type not in response.headers + is_json = False + + if is_json: answers = response.json() else: answers = [{ @@ -44,6 +50,7 @@ def send_request(self, method, uri, data=None, params=None): 'Message': response.text }] + if response.status_code >= 400: errors = []