Skip to content

Commit 1328f92

Browse files
committed
Updated 'dict' handling for responses without a body to use an empty dictionary
Signed-off-by: Mike Raineri <michael.raineri@dell.com>
1 parent ad73ed1 commit 1328f92

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/redfish/rest/v1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ def text(self, value):
249249
def dict(self):
250250
"""Property for accessing the data as an dict"""
251251
try:
252+
if len(self.text) == 0:
253+
# No response body; return empty dict instead to avoid exceptions
254+
# No response bodies can be valid in many cases (especially 4XX and 5XX responses)
255+
return {}
252256
return json.loads(self.text)
253257
except:
254258
str = "Service responded with invalid JSON at URI {}\n{}".format(

0 commit comments

Comments
 (0)