[GIS] How to upload shapefile to PostGIS using cURL and GeoServer REST API

geoserverpostgisrestshapefile

The GeoServer REST API docs here does not detail how to do this. I'd like to create a PostGIS table and corresponding featureType in GeoServer using the REST API, without having to chain requests.

For now I can upload a shapefile to geosever, but not to PostGIS. I can also create a PostGIS data store in a separate request. Unfortunately, its not possible to use an existing PostGIS data store when uploading a new shapefile. Anyone with experience on how to achieve, please assist.

Best Answer

I don't think you can do this using GeoServer - it isn't what the REST interface (or GeoServer) was designed to do. You need to use shp2psql (or any other uploader like ogr2ogr) to add shapefiles to PostGIS. The GeoServer REST interface is designed for adding new stores/layers etc to GeoServer.