views:

252

answers:

1

Hi,

I'm trying to upload a shape file with REST API. Here is the error I get : No such datastore: ws1,nete

I've installed version 1.7.5 together with the restconfig-1.7.5.jar plugin.

Here is what I do: 1) Create workspace ws1

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d 'ws1'localhost:8080/geoserver/rest/workspaces

2) Check workspace

curl -XGET -H 'Accept: text/xml' localhost:8080/geoserver/rest/workspaces/ws1

reply is ok

3) Upload shapefile

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @roads.zip localhost:8080/geoserver/rest/workspaces/ws1/datastores/roads/file.shp

Reply:

Warning: Couldn't read data from file "roads.zip", this makes an empty POST. Error occured unzipping file:error in opening zip

need help please!!!

A: 

I asked myself the same problem today, and solved it finally. I am running Geoserver 2.0.2 with REST extension.

The following curl command is working:

curl -u admin:geoserver -v -XPUT -H 'Content-type: application/zip' --data-binary @/home/shape.zip http://localhost:8085/geoserver/rest/workspaces/ws/datastores/test1/file.shp

The "file" in front of ".shp" is arbitrary, use what you like.

"test1" is the name of the new datastore.

"/home/shape.zip" is path to a zipped Shapefile. Note: A Shapefile consists of multiple files! See wIkipedia for an introduction. A zipped Shapefie for Geoserver should at least contain .shp, .dbf, .shx, .prj.

If you are developing in Java, you might want to use a Java client to configure Geoserver via REST. GSRCJ (http://code.google.com/p/gsrcj) is a very small (2 classes, zero dependencies) client written in Java 1.5+. It is not a complete implementation, but has working code of how to upload a Shapefile to Geoserver and more. See the code here.

alfonx