2

I am currently experimenting with the GeoServer ReST-API andy trying to update the configuration parameters of an ImageMosaic Coveragestore. I've been using Python 2.7 with the requests package as well as cURL, but after sending my POST-Request the layer isn't marked as active anymore in the GeoServer web interface.

enter image description here

I've saw this Message on the geoserver user mailing list and tried to reproduce this but without having success. No matter if I'm using Python or cURL, the POST-request does not update the specific entry in the parameters but overwrites all entries with only the one I specified in my request.

So here is my Python Code:

import requests

url = "http://MyGeoServer:8080/geoserver/rest/workspaces/Imaging_DOP/coveragestores/Geobasis_1410AB/coverages/Geobasis_1410AB.xml" 
headers = {'Content-Type': 'text/xml'}
auth = ('user', 'password')

data = """
<coverage>
<parameters>
    <entry>
        <string>AllowMultithreading</string>
        <string>true</string>
    </entry>
    <enable>true</enable>
</parameters>
</coverage>
"""
r = requests.put(url, headers=headers, auth=auth, data=data)
print r.status_code

And here is the same request with cURL:

curl -u user:password -v -XPUT -H 'Content-type: text/xml' -d '<coverage><parameters><entry><string>AllowMultithreading</string><string>true</string></entry><enable>true</enable></parameters></coverage>' http://MyGeoServer:8080/geoserver/rest/workspaces/Imaging_DOP/coveragestores/Geobasis_1410AB/coverages/Geobasis_1410AB.xml

Does anybody know how to update specific parameters in CoverageStores without replacing all the entries, except the one specified in the request and without making the layer unusable?

3

I managed this by making a GET request for the coverage:

curl -v -u admin:geoserver -H 'Accept: text/xml' -XGET http://localhost:8080/geoserver/rest/workspaces/nurc/coveragestores/mosaic/coverages/mosaic > req.xml

editing the required change into the file and then PUTting it

curl -v -u admin:geoserver -H 'Accept: text/xml' -H 'Content-type: text/xml' -XPUT -d@req.xml http://localhost:8080/geoserver/rest/workspaces/nurc/coveragestores/mosaic/coverages/mosaic

I'm sure there is a pythonic way to edit the XML returned from the first call too :-)

I can't find any reference in the API Docs that suggests that partial XML documents are an acceptable thing to send to the service.

  • Thanks, I used your answer to create a new WMS layer and a POST worked for me. – Freeze Apr 10 '17 at 15:52
  • if it solved your problem, please mark it as accepted by clicking on the tick mark. this will help future users with the same issue – Ian Turton Sep 20 '17 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.