Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if "location" in response.headers:
return response.headers["location"]
else:
try:
response_json = response.json()
except json.decoder.JSONDecodeError:
logging.warning('did not receive any json data back')
else:
if '_meta' in response_json and 'href' in response_json['_meta']:
return response_json['_meta']['href']
else:
return response_json
elif response.status_code == 412:
raise CreateFailedAlreadyExists("Failed to create the object because it already exists - url {}, body {}, response {}".format(url, json_body, response))
else:
raise CreateFailedUnknown("Failed to create the object for an unknown reason - url {}, body {}, response {}".format(url, json_body, response))
if "location" in response.headers:
return response.headers["location"]
else:
try:
response_json = response.json()
except json.decoder.JSONDecodeError:
logging.warning('did not receive any json data back')
else:
if '_meta' in response_json and 'href' in response_json['_meta']:
return response_json['_meta']['href']
else:
return response_json
elif response.status_code == 412:
raise CreateFailedAlreadyExists("Failed to create the object because it already exists - url {}, body {}, response {}".format(url, json_body, response))
else:
raise CreateFailedUnknown("Failed to create the object for an unknown reason - url {}, body {}, response {}".format(url, json_body, response))