开发者

Delete a workspace (geoserver) using curl and C#

I searched and didn't found how can I delete a workspace using cur开发者_如何转开发l and C#,

I can create a workspace with Curl and C# but I don´t know if I can delete the workspace using the same tools

Thanks in advance

       string url = "http://xxxxxxxxxxx:8080/geoserver/rest/workspaces";
        WebRequest request = WebRequest.Create(url);

        request.ContentType = "text/xml";
      request.Method = "DELETE";


        string authInfo = "xxxx:xxxxxxx";

        request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(authInfo));

        byte[] buffer = Encoding.GetEncoding("UTF-8").GetBytes("<workspace><name>testWorkspace</name></workspace>");
        Stream reqstr = request.GetRequestStream();
        reqstr.Write(buffer, 0, buffer.Length);
        reqstr.Close();

        WebResponse response = request.GetResponse();


If you can create a workspace programatically, you should be able to delete one (assuming proper credentials).

Take a look at the docs for geoerver's REST API. Scroll down a bit to the Workspaces section and you'll notice that you need to send a DELETE method to the server for the workspace you want to delete.

Since you have your create working, you should have all the code you need in order to get the DELETE working.

EDIT

After taking a look at the code, I would change the request to use the URL

http://xxxxxxxxxxx:8080/geoserver/rest/workspaces/testWorkspace

and see if you still get a 405 when executing the delete.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜