Skip to content

Commit e4cfa2f

Browse files
handle 204 no content better
1 parent 4f02cfa commit e4cfa2f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

aidentified_matching_api/token_service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ def api_call(self, args, fn, url, **kwargs):
9494

9595
logger.info(f"{fn.__name__} {url}")
9696
try:
97-
resp = fn(f"{constants.AIDENTIFIED_URL}{url}", **kwargs)
98-
resp_obj = resp.json()
97+
resp: requests.Response = fn(f"{constants.AIDENTIFIED_URL}{url}", **kwargs)
98+
99+
if not resp.content:
100+
resp_obj = {}
101+
else:
102+
resp_obj = resp.json()
99103
except requests.RequestException as e:
100104
raise Exception(f"Unable to make API call: {e}") from None
101105

0 commit comments

Comments
 (0)