diff --git a/intercom/lib/flat_store.py b/intercom/lib/flat_store.py index 1c330436..7f426812 100644 --- a/intercom/lib/flat_store.py +++ b/intercom/lib/flat_store.py @@ -12,7 +12,8 @@ def __init__(self, *args, **kwargs): def __setitem__(self, key, value): if not ( isinstance(value, numbers.Real) or - isinstance(value, six.string_types) + isinstance(value, six.string_types) or + value is None ): raise ValueError( "custom data only allows string and real number values") diff --git a/intercom/request.py b/intercom/request.py index c19ccecf..ad846709 100644 --- a/intercom/request.py +++ b/intercom/request.py @@ -42,10 +42,13 @@ def send_request_to_path(cls, method, url, auth, params=None): @classmethod def parse_body(cls, resp): try: - # use supplied encoding to decode the response content - decoded_body = resp.content.decode(resp.encoding) - if not decoded_body: # return early for empty responses (issue-72) + # return early for empty responses (issue-72) + if not resp.content or not resp.content.strip(): return + # use supplied encoding to decode the response content + decoded_body = resp.content.decode( + resp.encoding or resp.apparent_encoding + ) body = json.loads(decoded_body) if body.get('type') == 'error.list': cls.raise_application_errors_on_failure(body, resp.status_code)