Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
Import API
Commits
179258fa
Commit
179258fa
authored
Apr 12, 2021
by
Jonas Waeber
Browse files
Add url to log
parent
195a60bc
Pipeline
#24474
passed with stages
in 2 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
import_api_app/resources/WriteTypeReportToDrupal.py
View file @
179258fa
...
...
@@ -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
}
."
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment