I'm new to geonetwork and got a question that need your help.
I'm trying to learn how to update metadata programatically using python.
I have a sample xml file, and would like to use it to update the metadata
for a record. The sample xml was originally downloaded from a ISO-format
sample layer of geonetwork and was slightly modified (I changed "abstract"
and "purpose"). I want to import it back to geonetwork and be able to see
the changed I made.
Here is my code:
from owslib.csw import CatalogueServiceWeb
csw = CatalogueServiceWeb('http://localhost:8080/geonetwork/srv/en/csw’)
contents = open('/home/ran/Downloads/test.xml').read()
csw.getrecordbyid(id=['693f5171-e5bc-4b54-847c-b3562b31ee05'])
csw.transaction(ttype='update', record=contents)
print csw.response
The above code didn't work by giving me an error message:
!image.png|789x297
How do I update metadata correctly? I also attached the sample.xml for
your reference.
In your snippet I don't see any login, that is required to be able to use
CSW Transaction operations. Also Geonetwork for CSW Transaction work with
csw-publication end-point, not with csw end-point.
On Wed, May 29, 2019 at 7:48 PM Ran L. <kula009@anonymised.com> wrote:
Hello,
I'm new to geonetwork and got a question that need your help.
I'm trying to learn how to update metadata programatically using python.
I have a sample xml file, and would like to use it to update the metadata
for a record. The sample xml was originally downloaded from a ISO-format
sample layer of geonetwork and was slightly modified (I changed "abstract"
and "purpose"). I want to import it back to geonetwork and be able to see
the changed I made.
Here is my code:
from owslib.csw import CatalogueServiceWeb
csw = CatalogueServiceWeb('http://localhost:8080/geonetwork/srv/en/csw’)
contents = open('/home/ran/Downloads/test.xml').read()
csw.getrecordbyid(id=['693f5171-e5bc-4b54-847c-b3562b31ee05'])
csw.transaction(ttype='update', record=contents)
print csw.response
The above code didn't work by giving me an error message:
[image: image.png]
How do I update metadata correctly? I also attached the sample.xml for
your reference.