Commit 195a60bc authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix style

parent 929c9284
Pipeline #24471 passed with stages
in 2 minutes and 14 seconds
......@@ -46,10 +46,10 @@ class WriteTypeReportToDrupal(Resource):
"""
try:
node_type = request.json[0]['node_type']
identifier = request.json[0]['id']
status = request.json[0]['status']
report = request.json[0]['report']
node_type = request.json['node_type']
identifier = request.json['id']
status = request.json['status']
report = request.json['report']
except KeyError as er:
return {
'message': f'Missing a element in input body: {er}'
......@@ -79,7 +79,14 @@ def get_node_id(memobase_id: str):
response = requests.get(url, headers=headers)
if response.ok:
return response.json()['data'][0]['attributes']['id']
try:
return response.json()['data'][0]['attributes']['id']
except KeyError as er:
current_app.logger.error(f"Could not find the key {er} in data: {response.text}.")
raise ImportApiError(f"Could not find the key {er} in data: {response.text}.")
except IndexError:
current_app.logger.error(f"Data field does not contain a list: {response.text}.")
raise ImportApiError(f"Data field does not contain a list: {response.text}.")
else:
raise ImportApiError(f"Could not find element for report: {response.text}.")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment