Re: [Geoserver-users] Create Directory of Shape files Datastore with REST API JSON
I've been dealing with this situation for a couple of days now and here's what I found First, your original question includes an example that WORKS if you POST it to /rest/workspaces/topp/datastores.json with a header setting Content-type: application/json. It will create a datastore of the type Shapefile even if your url parameters point to a directory that holds a shapefile. (/I thought I should mention this because the web interface only lets you create a Shapefile datastore if you point 'url' to an specific shapefile and won let you pick just a directory/). Your example doesn't work if you POST it to /rest/workspaces/myWorkspace/datastores/name because that's not the REST endpoint for creating datastores. This is the minimum object you should POST if you specifically want to create a data store of the type Directory of spatial files (shapefiles) instead of Shapefile datastore. dataStore: { name: name, type: Directory of spatial files (shapefiles), connectionParameters: { url: file:data/shapefiles, fstype: shape } } What Andreas said is true. geowolf wrote Whenever something is not documented there is an easy way to discover the data structure you need: * go into the user interface, create the objects you need * go into the rest api, and grab their xml/json representation The problem with this being seamlessly useful is a REST API implementation detail that makes it represent some plain objects in a strange way when you ask the API for a JSON representation about any resource. I mean, when the REST API tells you something like connectionParameters:{ entry:[ {@key:memory mapped buffer,$:false}, {@key:fstype,$:shape} ] } it means that what you have to POST for a new datastore is: connectionParameters:{ memory mapped buffer:false, fstype:shape } I think this is due to Geoserver or the REST module using a specific library to convert to JSON objects that behaves in that way when serializing a JAVA object -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Create-Directory-of-Shape-files-Datastore-with-REST-API-JSON-tp5144395p5147893.html Sent from the GeoServer - User mailing list archive at Nabble.com. -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Geoserver-users mailing list Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users
Re: [Geoserver-users] Create Directory of Shape files Datastore with REST API JSON
I've been dealing with this situation for a couple of days now and here's what I found First, your original question includes an example that WORKS if you POST it to /rest/workspaces/topp/datastores.json with a header setting Content-type: application/json. It will create a datastore of the type Shapefile even if your url parameters point to a directory that holds a shapefile. (/I thought I should mention this because the web interface only lets you create a Shapefile datastore if you point 'url' to an specific shapefile and won let you pick just a directory/). Your example doesn't work if you POST it to /rest/workspaces/myWorkspace/datastores/name because that's not the REST endpoint for creating datastores. This is the minimum object you should POST if you specifically want to create a data store of the type Directory of spatial files (shapefiles) instead of Shapefile datastore. dataStore: { name: name, type: Directory of spatial files (shapefiles), connectionParameters: { url: file:data/shapefiles, fstype: shape } } What Andreas said is true. geowolf wrote Whenever something is not documented there is an easy way to discover the data structure you need: * go into the user interface, create the objects you need * go into the rest api, and grab their xml/json representation The problem with this being seamlessly useful is a REST API implementation detail that makes it represent some plain objects in a strange way when you ask the API for a JSON representation about any resource. I mean, when the REST API tells you something like connectionParameters:{ entry:[ {@key:memory mapped buffer,$:false}, {@key:fstype,$:shape} ] } it means that what you have to POST for a new datastore is: connectionParameters:{ memory mapped buffer:false, fstype:shape } I think this is due to Geoserver or the REST module using a specific library to convert to JSON objects that behaves in that way when serializing a JAVA object -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Create-Directory-of-Shape-files-Datastore-with-REST-API-JSON-tp5144395p5147634.html Sent from the GeoServer - User mailing list archive at Nabble.com. -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Geoserver-users mailing list Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users