diff --git a/src/opengnsys/RESTApi.py b/src/opengnsys/RESTApi.py index 8773cf5..3e3468f 100644 --- a/src/opengnsys/RESTApi.py +++ b/src/opengnsys/RESTApi.py @@ -142,6 +142,10 @@ class REST(object): else: r = requests.post(url, data=data, headers={'content-type': 'application/json'}) + r.raise_for_status() + ct = r.headers['Content-Type'] + if 'application/json' != ct: + raise Exception (f'response content-type is not "application/json" but "{ct}"') r = json.loads(r.content) # Using instead of r.json() to make compatible with old requests lib versions except requests.exceptions.RequestException as e: raise ConnectionError(e)