Update metadata record through records API using Python
Due to using the wrong email alias this wasn't delivered back to the
mailing list as intended earlier.
Thanks so much for your help Jo, it's working! I got it to work with your
pointers using the "batchediting" path. I'll try to be as concise as
def __init__(self) -> None:
# You need to set
self.portal = '<a href="http://localhost:8080'">http://localhost:8080' self.catalogue_user = 'my_gn_user_account'
self.catalogue_password = 'some_secret'
self.record_id = '00000000-0000-0000-0000-000000000000'
assert response.status_code == 201, f'Error updating record: status
I hope this brings across the gist of the operation. Please check whether
the xpath matches for your purpose: we use the 'edition' metadata element
to store our data version info (perhaps there is a better one, but this is
fine I guess).
There was one thing I noticed though: you need to pay exceptional care to
what the response json contains. Whether you try to update existing or
non-existing xpaths, it will give you a 201 response regardless. Inspection
of the response json on having some kind of content is prudent. A
successful update will contain something like:
amongst a host of other keys and values. On a bad xpath, you will get
So an empty 'metadataInfos' value for a mismatched xpath. So apart from the
response status assertion, you may want to parse the response json and
check that the 'metadataInfos' value contains at least one key.