I was wondering if there is any example of using REST API with curl to delete a coverage store?
I looked at the examples at the boundless website http://docs.geoserver.org/2.5.x/en/user/rest/examples/curl.html, and there doesn't seem to be any.
I tried:
curl -v -u admin:geoserver -X DELETE http://localhost:8080/geoserver/rest/my_ws/coveragestores/my_cover
and
curl -v -u admin:geoserver -X DELETE http://localhost:8080/geoserver/rest/my_ws/coveragestores/my_cover?recurse=true
In each case, I get an 405 Method Not Allowed
.
Can anyone advise how to fix this?
Output error was:
> DELETE /geoserver/rest/my_ws/coveragestores/my_cover?recurse=true&purge=all HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 405 Method Not Allowed
< Allow: GET
< Date: 2014年10月20日 01:24:28 GMT
< Server: Noelios-Restlet-Engine/1.0..8
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
--- EDIT ---
Additional Info:
$curl -v -u admin:geoserver -XGET -H "Accept: text/xml" http://localhost:8080/geoserver/rest/workspaces/my_ws/coveragestores.xml
returns:
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1... connected
* Server auth using Basic with user 'admin'
> GET /geoserver/rest/workspaces/my_ws/coveragestores.xml HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:8080
> Accept: text/xml
>
< HTTP/1.1 200 OK
< Date: 2014年10月20日 02:53:53 GMT
< Server: Noelios-Restlet-Engine/1.0..8
< Content-Type: application/xml
< Transfer-Encoding: chunked
<
<coverageStores>
<coverageStore>
<name>my_cover</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/my_ws/coveragestores/my_cover.xml" type="application/xml"/>
</coverageStore>
* Connection #0 to host localhost left intact
* Closing connection #0
</coverageStores>
1 Answer 1
Try this:
curl -v -u admin:geoserver -XDELETE http://localhost:8080/geoserver/rest/my_ws/coveragestores/my_cover?recurse=true
You have a space between -X
and DELETE
Example can be seen at the REST API Docs
curl -v -u admin:geoserver -XDELETE "http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/polyphemus-v1/coverages/NO2/index/granules.xml?filter=location='polyphemus_20130301.nc'"
Additionally, the end point should be:
/rest/workspaces/my_ws1
-
Thanks a lot for your answer. I tried your version without the space between -X and DELETE, the result is the same. This is with GeoServer 2.5.tinlyx– tinlyx2014年10月20日 02:23:57 +00:00Commented Oct 20, 2014 at 2:23
-
What coverage type are you using, what command did you use to create it?Mark Cupitt– Mark Cupitt2014年10月20日 02:24:53 +00:00Commented Oct 20, 2014 at 2:24
-
It's a GeoTIFF image, store created with GeoServer GUI. Actually, the command gives me
405 Method Not Allowed
even if I use an non-existing coverage name such asmy_cover1
.tinlyx– tinlyx2014年10月20日 02:29:42 +00:00Commented Oct 20, 2014 at 2:29 -
I suspect it is a naming issue. Use the REST API to LIST the overages and check what is actually there and what name is returned. I suspect it may be a coverage and not a coverage store that you need to refer to.Mark Cupitt– Mark Cupitt2014年10月20日 02:33:51 +00:00Commented Oct 20, 2014 at 2:33
-
This is how to get the coverage and datastores in the work space:
curl -v -u admin:geoserver -XGET -H "Accept: text/xml" http://localhost:8080/geoserver/rest/workspaces/acme
Mark Cupitt– Mark Cupitt2014年10月20日 02:41:10 +00:00Commented Oct 20, 2014 at 2:41
Explore related questions
See similar questions with these tags.