I have a folder containing shape files for a few dozen layers.
On my development server, I created a Directory of Spatial files store in my workspace, then published each one, one at a time, with the UI. Create the layer, select the store, click publish next to the next shapefile name, click calculate bounds, click calculate lat/long bounds, click Publish tab, set default style, Submit. Repeat for each layer.
Now I'm setting up a production environment. I've installed GeoServer, and would like to import all these layers. I've never used the REST API's, but am quickly coming up to speed. I've used CURL / REST to create my workspace. Now I'm trying to create my datastore. I haven't found an example to setup a "Directory of spatial files" datastore. I queried my existing store, so I can see the XML (or JSON) to post, but I get nothing as a response (I use -o option of CURL, but the output file is empty).
Here is the CURL command I use:
curl -u admin:geoserver -v -XPOST -H 'Content-type:text/xml' -T My_datastore.xml -o CreateMyDataStore.out http://localhost:8080/geoserver/rest/workspaces/MyWorkspace/datastores
The My_datastore.xml file looks like this:
<dataStore> <name>MyDatastore</name> <type>Directory of spatial files (shapefiles)</type> <connectionParameters> <entry key="charset">ISO-8859-1</entry> <entry key="filetype">shapefile</entry> <entry key="create spatial index">true</entry> <entry key="memory mapped buffer">false</entry> <entry key="timezone">America/New_York</entry> <entry key="enable spatial index">true</entry> <entry key="namespace">http://www.opengeospatial.net/cite</entry> <entry key="cache and reuse memory maps">true</entry> <entry key="url">file://C:\Geo Server\MyFolder</entry> <entry key="fstype">shape</entry> </connectionParameters> </dataStore>
The file directory "C:\Geo Server\MyFolder" is the same name used to create the datastore on the development machine...
The output I get at the command prompt when I run the CURL command is as follows:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8080 (#0) * Server auth using Basic with user 'admin' > POST /geoserver/rest/workspaces/MyWorkspace/datastores HTTP/1.1 > Host: localhost:8080 > Authorization: Basic YWRtaW46Z2Vvc2VydmVy > User-Agent: curl/7.61.1 > Accept: */* > 'Content-type:application/xml' > Content-Length: 614 > Expect: 100-continue > < HTTP/1.1 100 } [614 bytes data] * We are completely uploaded and fine < HTTP/1.1 415 < X-Frame-Options: SAMEORIGIN < Access-Control-Allow-Origin: * < Accept: application/json, text/json, application/xml, text/xml < Content-Length: 0 < Date: Thu, 25 Oct 2018 03:25:30 GMT < Connection: close < 100 614 0 0 100 614 0 1710 --:--:-- --:--:-- --:--:-- 1710 * Closing connection 0
I see the Error 415, but it doesn't make sense. I've specified "text/xml" and it is one of the accepted content types.
Anybody see anything subtle or glaringly obvious that I missed? Can I not create this type of store through the REST API? I'd love to be able to automate this so I can fully automate the install/configuration of new production GeoServers (as they run locally at the customer site).