Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Created March 19, 2022 14:24
Show Gist options
  • Save mdiener21/775d059e81ad43111caddcd190c58d0d to your computer and use it in GitHub Desktop.
Save mdiener21/775d059e81ad43111caddcd190c58d0d to your computer and use it in GitHub Desktop.
Delete a geoserver layer using the API with Python Requests
import requests
def delete_layer(layer_name):
s = requests.Session()
GEOSERVER_USER = 'someusername'
GEOSERVER_PASS = 'asecretthingy'
s.auth = (GEOSERVER_USER, GEOSERVER_PASS)
headers_json = {'Content-type': 'application/json', }
del_url = "https:/yourgeoserver.com/workspaces/SsmeWorkspaceName/datastores/someDataStoreName/featuretypes/" + layer_name + "?recurse=true"
r = s.delete(del_url, headers=headers_json, data={})
@mdiener21
Copy link
Author

Ah blog plug to myself, some details are found here: my blog post to as to how to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment