From 25c29b61a2503a0d0ebdf90d5926e0c90bd61225 Mon Sep 17 00:00:00 2001 From: Kevin Bates Date: Mon, 13 Jan 2020 07:25:48 -0800 Subject: [PATCH] Handle responses with empty content (#77) Application submission via the REST API does not return a response body. This updates ensures that an empty dictionary is returned in such cases. Fixes: #76 --- yarn_api_client/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yarn_api_client/base.py b/yarn_api_client/base.py index 58da79b..ee9ca1e 100644 --- a/yarn_api_client/base.py +++ b/yarn_api_client/base.py @@ -19,8 +19,12 @@ class Response(object): :param requests.Response response: Response for call via requests lib """ def __init__(self, response): - #: Dictionary with response data - self.data = response.json() + #: Dictionary with response data. Handle cases where content is empty + # to prevent JSON decode issues + if response.content: + self.data = response.json() + else: + self.data = {} class Uri(object):