Geoserver : enable services for a specific workspace

42 Views Asked by At

I'm working on automation to fully configure my Geoserver intance. Thanks to the REST API (https://docs.geoserver.org/main/en/user/rest/api/workspaces.html) I'm able to create automatically my workspace.

Now I would like to automatically enable all the services:

enter image description here

I tried to use the endpoint /services/wms/workspaces/{workspace}/settings but it fails: I receive an error 500. In term of data, I just passed (as JSON): enabled: true

I have to admit that I don't understand how this endpoint works (and if it is the one I need).

Is someone has an idea how to enable these services please :-) ?

Thank you very much

2

There are 2 best solutions below

0
Ian Turton On BEST ANSWER

Request the existing file from the server using GET and modify that file and send it back. If you continue to have issues with JSON, try XML and if that works consider asking for an enhancement.

0
kortex On

I tried what you mentioned and it works properly: thank you very much.

If it can help someone, here is an example to enable WMS in a workspace named myworkspace:

  • Download the global settings file:
https://<GEOSERVER_URL>/geoserver/rest/services/wms/settings.xml
  • Set a variable with the content of the setting file

  • Active the service in my workspace:

    • URL called: https://<GEOSERVER_URL>/geoserver/rest/services/wms/workspaces/myworkspace/settings
    • method: PUT
    • data passed: content of the variable created in #2
    • headers:
      • Content-Type: application/xml

It works for other services too: WCS, WFS, WMS, WMTS

Thank you very much @Ian Turton