I am trying to add a shapefile datastore to a geoserver 2.0.2 instance. I have been able to get it to work using the following command
curl -u admin:geoserver -v -XPUT -H ‘Context-type: application/zip’ --data-binary ‘/home/path/to/test.zip’ http://localhost:8080/geoserver/rest/workspaces/sf/datastore/sf/file.shp
However I already have the shape files stored in a particular directory and I simply want to reference them. When I try the following command which I was told by a guy in the open-geo booth at FOSS4G-2010 it gives me an error.
curl -u admin:geoserver -v -XPUT -H ‘Content-type: text/plain’ -d ‘/home/path/to/test.shp’ http://localhost:8080/geoserver/rest/workspaces/sf/datastores/sf/external.shp
- About to connect() to localhost port 8080 (#0)
- Trying ::1… connected
- Connected to localhost (::1) port 8080 (#0)
- Server auth using Basic with user ‘admin’
PUT /geoserver/rest/workspaces/sf/datastores/sf/external.shp HTTP/1.1
Authorization: Basic YWRtaW46Z2Vvc2VydmVy
User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Host: localhost:8080
Accept: /
Content-type: text/plain
Content-Length: 20
< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< Server: Jetty(6.1.8)
<
- Connection #0 to host localhost left intact
- Closing connection #0
Could not determine format. Try setting the Content-type header.
It is supposedly telling me that the text/plain content type is unknown but I can’t get any other combination other then application/zip to work.
Can anyone say what I’m doing wrong or is what I’m trying to do not posible and I need to program my own restful interface to do it.
John
I posted this question yesterday with no replies. Is it that few use the restful interface, and I should just work out my own solution, or did I post it to the wrong list.
John
On Thu, Sep 23, 2010 at 10:13 AM, John Preston <byhisdeeds@anonymised.com> wrote:
I am trying to add a shapefile datastore to a geoserver 2.0.2 instance. I have been able to get it to work using the following command
curl -u admin:geoserver -v -XPUT -H ‘Context-type: application/zip’ --data-binary ‘/home/path/to/test.zip’ http://localhost:8080/geoserver/rest/workspaces/sf/datastore/sf/file.shp
However I already have the shape files stored in a particular directory and I simply want to reference them. When I try the following command which I was told by a guy in the open-geo booth at FOSS4G-2010 it gives me an error.
curl -u admin:geoserver -v -XPUT -H ‘Content-type: text/plain’ -d ‘/home/path/to/test.shp’ http://localhost:8080/geoserver/rest/workspaces/sf/datastores/sf/external.shp
- About to connect() to localhost port 8080 (#0)
- Trying ::1… connected
- Connected to localhost (::1) port 8080 (#0)
- Server auth using Basic with user ‘admin’
PUT /geoserver/rest/workspaces/sf/datastores/sf/external.shp HTTP/1.1
Authorization: Basic YWRtaW46Z2Vvc2VydmVy
User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Host: localhost:8080
Accept: /
Content-type: text/plain
Content-Length: 20
< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< Server: Jetty(6.1.8)
<
- Connection #0 to host localhost left intact
- Closing connection #0
Could not determine format. Try setting the Content-type header.
It is supposedly telling me that the text/plain content type is unknown but I can’t get any other combination other then application/zip to work.
Can anyone say what I’m doing wrong or is what I’m trying to do not posible and I need to program my own restful interface to do it.
John
Generally we encourage users of the REST API to ask on the users list (you’d have to be working with the actual code of GeoServer to cross over into -devel territory). I think the REST API is used by a relatively small number of people compared to those who use GeoServer in general, but the ‘upload a shapefile’ use case is pretty typical of what those users are doing. However, I don’t believe the REST API supports uploading non-zipped shapefiles right now. If it did, you would need to provide at least the .shp, .dbf, and .shx files; the .shp is not sufficient by itself.
There are actually multiple things wrong with your sample request (posting a single .shp file without the accompanying .shx and .dbf, using text/plain for the mimetype, using PUT when you want to create a new object), so I expect most developers on this list were too busy with other work to break it down here.
–
David Winslow
OpenGeo - http://opengeo.org/
On Fri, Sep 24, 2010 at 12:38 PM, John Preston <byhisdeeds@anonymised.com> wrote:
I posted this question yesterday with no replies. Is it that few use the restful interface, and I should just work out my own solution, or did I post it to the wrong list.
John
On Thu, Sep 23, 2010 at 10:13 AM, John Preston <byhisdeeds@anonymised.com> wrote:
I am trying to add a shapefile datastore to a geoserver 2.0.2 instance. I have been able to get it to work using the following command
curl -u admin:geoserver -v -XPUT -H ‘Context-type: application/zip’ --data-binary ‘/home/path/to/test.zip’ http://localhost:8080/geoserver/rest/workspaces/sf/datastore/sf/file.shp
However I already have the shape files stored in a particular directory and I simply want to reference them. When I try the following command which I was told by a guy in the open-geo booth at FOSS4G-2010 it gives me an error.
curl -u admin:geoserver -v -XPUT -H ‘Content-type: text/plain’ -d ‘/home/path/to/test.shp’ http://localhost:8080/geoserver/rest/workspaces/sf/datastores/sf/external.shp
- About to connect() to localhost port 8080 (#0)
- Trying ::1… connected
- Connected to localhost (::1) port 8080 (#0)
- Server auth using Basic with user ‘admin’
PUT /geoserver/rest/workspaces/sf/datastores/sf/external.shp HTTP/1.1
Authorization: Basic YWRtaW46Z2Vvc2VydmVy
User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Host: localhost:8080
Accept: /
Content-type: text/plain
Content-Length: 20
< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< Server: Jetty(6.1.8)
<
- Connection #0 to host localhost left intact
- Closing connection #0
Could not determine format. Try setting the Content-type header.
It is supposedly telling me that the text/plain content type is unknown but I can’t get any other combination other then application/zip to work.
Can anyone say what I’m doing wrong or is what I’m trying to do not posible and I need to program my own restful interface to do it.
John
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
Geoserver-devel mailing list
Geoserver-devel@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel