Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

As part of a possible solution to this question i want create a layer in GeoServer via REST that supplies a SQL statement along with a userid.

Reading I think i would create a feature type and publish it? I need to do this all in REST. Does anyone have any code examples?

share|improve this question

3 Answers 3

up vote 14 down vote accepted

There are many things you can do with the GeoServer REST API that are not specifically documented and that there are not code examples for. Here's the strategy for tackling those.

First, start with the examples in the documentation. Make sure you are familiar with how you can create a simple new layer or workspace using an HTTP POST with either XML or JSON.

Then, through the GeoServer UI, manually create the object you need for which there is no documentation (in this case, a feature type).

Finally, manually browse to the GeoServer REST index (http://your-server/rest or http://your-server/geoserver/rest). Browse through the index until you find the feature type you just created. Append ".xml" or ".json" to the URL of this resource, and you will see its XML or JSON representation.

This representation is what you would have needed to POST to create the feature type through the API. The URL of the representation is the URL that you would have needed to POST to (for example, http://your-server/geoserver/rest/..../myFeatureTypeName.json).

You can use this strategy to figure out how to programmatically create or configure any resource in GeoServer.

share|improve this answer
    
THANK YOU! Easy answer and just saved me another 2 hours of mocking around –  Ragi Yaser Burhum Mar 3 '12 at 0:24
1  
In addition, a lot of the parameters can be skipped, and GeoServer will figure them out (just like in the UI). eg. bounding boxes –  rcoup Mar 7 '12 at 4:21

If you understand Java you might want to take a look at this simple code that uses REST to do all kinds of operations on GeoServer.

share|improve this answer

Your best reference is in the user guide. http://docs.geoserver.org/stable/en/user/restconfig/rest-config-examples/index.html

share|improve this answer
    
Yeah, but there is no example for creating a feature type from a SQL statement... i was hoping someone had example code to share. –  CaptDragon Aug 2 '11 at 14:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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