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:

    <type>Directory of spatial files (shapefiles)</type>
        <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>

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...
* 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).

  • I have facing same issue. Can you reslove step by step.
    – Rajeev
    Commented Oct 25, 2018 at 14:19
  • To create the store containing shapefiles, use the CURL command above, with the XML above ( you had to create the workspace first, or use "cite" for the default workspace. Just fix the single quotes in the CURL command to double quotes, and it should work fine.
    – Brian B
    Commented Oct 25, 2018 at 15:25
  • Then you need to publish each shp file by name individually with a similar CURL command. Here is an example for the "roads" shape file in workspace YOURWORKSPACE and in the datastore named YOURSTORENAME... curl -u admin:geoserver -v -XPOST -H 'Content-type:text/xml' -d "<featureType><name>roads</name><nativeName>roads</nativeName><title>roads</title><keywords><string>features</string><string>roads</string></keywords></featureType>" localhost:8080/geoserver/rest/workspaces/YOURWORKSPACE/…
    – Brian B
    Commented Oct 25, 2018 at 15:26

1 Answer 1


Ah, I've found it. I didn't notice the 415 error until I was finished writing the question. The CURL example must not have been for Windows, I'm guessing, because when I surround my Content-type sting with double quotes instead of single quote, the store gets created successfully.

So I guess this is really an example of how to do it properly, with the exception of the quotes around that string.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.