I receive an HTTP 500 internal server error when attempting to PUT a shapefile using REST API. I can manually import the file, publish and preview it. So the file is fine.

GeoServer log:

2016-05-24 12:20:25,921 INFO [catalog.rest] - PUT file, mimetype: application/zip
2016-05-24 12:20:27,140 INFO [catalog.rest] - Auto-configuring datastore: testshapes
2016-05-24 12:20:27,140 ERROR [geoserver.rest] - 
at org.geoserver.catalog.rest.DataStoreFileResource.updateParameters(DataStoreFileResource.java:515)
at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreFileResource.java:271)
at org.restlet.Finder.handle(Finder.java:298)
at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:38)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Router.handle(Router.java:444)

Fiddler RAW view of request and response:

PUT http://localhost:8080/geoserver/rest/workspaces/test/datastores/testshapes/file.shp HTTP/1.1
Content-Type: application/zip
Authorization: Basic YWRtaW46Z2Vvc2VydmVy
Host: localhost:8080
Content-Length: 205898
Expect: 100-continue
Connection: Keep-Alive

HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Server: Jetty(6.1.8)


C# code:

public bool UploadShapeFile(string workspace, string newStoreName, byte[] fileContents)
    byte[] localShapeFile = fileContents;
    String sUrl = GEOSERVER_HOST + "workspaces/" + workspace + "/datastores/" + newStoreName + "/file.shp";
    WebRequest request = WebRequest.Create(sUrl);
    request.ContentType = "application/zip";
    request.Method = "PUT";
    request.Credentials = new NetworkCredential(GEOSERVER_USER, GEOSERVER_PASSWD);

    request.Headers.Add("Authorization", "Basic " +
    Convert.ToBase64String(Encoding.ASCII.GetBytes(GEOSERVER_USER + ":" + GEOSERVER_PASSWD)));

    Stream requestStream = request.GetRequestStream();
    requestStream.Write(localShapeFile, 0, localShapeFile.Length);

    WebResponse response = request.GetResponse();
    return false;


var c = new GeoServerClient.Endpoint(); 
var f =
c.UploadShapeFile("test", "testshapes", f);

I had the same issue, and it was resolved after setting the "Activate HTTP method matching", and checking PUT method.

Access your geoserver web interface ( http://localhost:8070/geoserver/web ), ans then: Authentication --> Filter Chains --> rest --> Check HTTP Method (check), PUT (check) --> hit 'close' and then 'save'

  • Your answer seems reasonable. Thanks. Pity you weren't around a year ago LOL – Captain Kenpachi Oct 3 '17 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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