1

I'm using GeoServer REST API to create a layer from a shapefile. That shapefile needs to be updated on a regular basis. Since there is no replace function on the REST API, I'm trying to delete the layer, replace the files and then recreate the layer with the new shapefile. pretty much like the answer at Uploading shapefile to GeoServer using cURL and replace file?

The problem I´m facing is that i´m receiving a 403 Forbidden message when I try to delete the layer. Since I have no problems publishing and editing layers I guess it is a security problem but have no clue of where I must change such security features.

The cURL command I´m sending is:

curl -v -u user:pass -XDELETE -H http://localhost:8080/geoserver/rest/layers/LayerName.xml

Sucth request gives me:

http/1.1 403 Forbidden
  • I tested with fresh GeoServer 2.7 installation and curl -u admin:geoserver -XDELETE http://localhost:8080/geoserver/rest/layers/topp:tasmania_cities.xml Layer got deleted but I had to delete first a layer group "tasmania" where it was belonging. – user30184 Oct 28 '15 at 22:41
6

I think I figured it out... After checking user30184 comment realized that I was sending petition to .../rest/layers/LayerName.xml Instead of ...rest/layers/workspace:tasmania_cities.xml

Tried then with: curl -v -u admin:geoserver -XDELETE "http://testdevt.fractanet.com.mx:181/geoserver/rest/layers/Workspace:layer.xml" and the layer disappeared. Then I tried to recreate the layer but geoserver told me that the layer was present on that datastore. Sent curl -v -u admin:geoserver -XDELETE "http://testdevt.fractanet.com.mx:181/geoserver/rest/workspaces/MyWorkspace/datastores/MyDatastore/featuretypes/Layername.xml" and now I can recreate the layer

  • great! useful answer – user1919 May 4 '18 at 12:59
1

I had a similar problem with PUT request using REST api, it gave 403 every time on dev server but was working fine on local server. I searched a lot and checked all settings... it turned out to be Tomcat had some filter settings which were blocking PUT request. When I changed those settings, it started working. Do check your tomcat filters maybe that is the reason for 403.

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.