Skip to content

Commit 25c29b6

Browse files
kevin-bateslresende
authored andcommitted
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
1 parent 2ea5f85 commit 25c29b6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

yarn_api_client/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ class Response(object):
1919
:param requests.Response response: Response for call via requests lib
2020
"""
2121
def __init__(self, response):
22-
#: Dictionary with response data
23-
self.data = response.json()
22+
#: Dictionary with response data. Handle cases where content is empty
23+
# to prevent JSON decode issues
24+
if response.content:
25+
self.data = response.json()
26+
else:
27+
self.data = {}
2428

2529

2630
class Uri(object):

0 commit comments

Comments
 (0)