REST API - Trying to create layer group using default layer style

Hello

I am trying to create with the REST API a layer group composed of:

  • a reference to another layer group, using the default style of the layer group
  • a reference to a WMS Remote layer, using the default style of the remote layer

I managed to create it in the admin UI. I used the REST API to get the definition of this layer group. The default style is indicated by an empty style element in the style list.

I tried to create the same group (after deleting it from geoserver) using the REST API and I get a 500 error. In the log, the stack complains because the style name is null (which is true since I didn’t provide it).

Is it a bug or is there a special syntax to manage the case ?

For my remote WMS layer, I can do a work around by using the name of the remote layer style. But for the layer group it is not possible, except if I create in my layer group a layer style with the same definition of my default one.

The layer stack:

java.lang.NullPointerException
        at org.geoserver.catalog.SLDNamedLayerValidator.validate(SLDNamedLayerValidator.java:65)
        at org.geoserver.catalog.impl.CatalogImpl.validate(CatalogImpl.java:1005)
        at org.geoserver.security.SecureCatalogImpl.validate(SecureCatalogImpl.java:1270)
        at org.geoserver.catalog.impl.AbstractFilteredCatalog.validate(AbstractFilteredCatalog.java:578)
        at org.geoserver.catalog.impl.AbstractCatalogDecorator.validate(AbstractCatalogDecorator.java:547)
        at org.geoserver.catalog.impl.LocalWorkspaceCatalog.validate(LocalWorkspaceCatalog.java:432)
        at org.geoserver.rest.catalog.LayerGroupController.layerGroupPost(LayerGroupController.java:156)

Hi Alex :slight_smile:
I think I have a similar use case, and I managed to make it work with this:
{'styles': {'style': [{'name': ''}, {'name': ''}]}}
The length of the list is the number of layers in the group.
Hope this helps

Hi Cecile,

Thank you for the help! It indeed solves my issue.

The only think is since the GET provides a reply without the element, it is not compatible with my terraform provider.