Commit 179258fa authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add url to log

parent 195a60bc
Pipeline #24474 passed with stages
in 2 minutes and 15 seconds
......@@ -65,7 +65,7 @@ class WriteTypeReportToDrupal(Resource):
f"{e.message}"}, 500
def get_node_id(memobase_id: str):
def get_node_id(memobase_id: str, node_type: str):
current_app.logger.debug(
f'Retrieve node id from durpal json api with memobase id {memobase_id}.')
headers = {
......@@ -74,7 +74,7 @@ def get_node_id(memobase_id: str):
'X-API-Key': current_app.config['drupal-cms-admin-key'],
'Authorization': 'Basic bWVtb2Jhc2U6MjAyMA=='
}
url = f'{current_app.config["drupal-api-url"]}/jsonapi/node/institution?filter[' \
url = f'{current_app.config["drupal-api-url"]}/jsonapi/node/{node_type}?filter[' \
f'field_memobase_id]={memobase_id} '
response = requests.get(url, headers=headers)
......@@ -83,10 +83,13 @@ def get_node_id(memobase_id: str):
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}.")
raise ImportApiError(f"Could not find the key {er} in data (url={url}): "
f"{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}.")
current_app.logger.error(f"Data field does not contain a list (url={url}): "
f"{response.text}.")
raise ImportApiError(f"Data field does not contain a list (url={url}): "
f"{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