3

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>
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 19, 2014 at 23:40

1 Answer 1

6

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
answered Oct 20, 2014 at 1:55
8
  • 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. Commented Oct 20, 2014 at 2:23
  • What coverage type are you using, what command did you use to create it? Commented 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 as my_cover1. Commented 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. Commented 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 Commented Oct 20, 2014 at 2:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.