I want to identify number of layers in to workspace in GeoServer for that I am using below REST API:


My application is running on IIS so I am using JSONP. I have enabled JSONP in GeoServer but I can not get output, always getting error "**Uncaught SyntaxError: Unexpected token :"

I tried:

var url  = "http://admin:geoserver@localhost:8080/geoserver/rest/workspaces/gisc/featuretypes.json?callback=?";

 type: 'GET',
 url: url,
 async: false,
    jsonpCallback: 'parseResponse', 
    contentType: "application/json",
    dataType: 'jsonp',  
    success: function(data)
    error: function (e)

I have also tried another combination but it won't work I am always getting same error.

I have also tried to enable CORS in Jetty using "org\mortbay\servlets\CrossOriginFilter.class" it works with WMS and WFS but won't work with featuretypes.json.

  • 1
    I think you are conflating two parts of geoserver, the REST API is for configuration and doesn't support JSONP. WFS does support JSONP and will need you to enable it and set CORS.
    – Ian Turton
    Mar 6 '17 at 15:14
  • In that case how can enable CORS for using REST API. or How can i get list of all layers in a workspace with different origin. Mar 6 '17 at 15:30
  • use the getCapabilities request
    – Ian Turton
    Mar 6 '17 at 15:47
  • With these I can not get all the coverage stores of workspace Mar 7 '17 at 11:28
  • yes you can - that is by definition the purpose of the getCapabilities request
    – Ian Turton
    Mar 7 '17 at 11:40

The GeoServer REST API is used purely for management of the GeoServer instance and should not be confused with the ESRI Rest interface.

If you want to interrogate GeoServer about layers you need to use one of the OGC open standard interfaces provided.

  • WMS - for rendered maps
  • WFS - for vector features
  • WCS - for raster coverages

In each case there is a well defined API which always includes a GetCapabilities request to tell you what operations and "layers" are available. These are always implemented as an HTTP GET request to the endpoint with the Key Value pairs of SERVICE and REQUEST=GetCapabilities and optionally a VERSION to determine the version of the specification you require.

If you are just trying to turn CORS on then see Enabling CORS in GeoServer (jetty)?

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.