Tag: geoserver

C#中使用C#进行用户身份validation

我想在c#中执行以下cURL请求: curl -u admin:geoserver -v -XPOST -H ‘Content-type: text/xml’ \ -d ‘acme’ \ http://localhost:8080/geoserver/rest/workspaces 我尝试过使用WebRequest: string url = “http://localhost:8080/geoserver/rest/workspaces”; WebRequest request = WebRequest.Create(url); request.ContentType = “Content-type: text/xml”; request.Method = “POST”; request.Credentials = new NetworkCredential(“admin”, “geoserver”); byte[] buffer = Encoding.GetEncoding(“UTF-8”).GetBytes(“my_workspace”); Stream reqstr = request.GetRequestStream(); reqstr.Write(buffer, 0, buffer.Length); reqstr.Close(); WebResponse response = request.GetResponse(); … 但是我收到一个错误:(400)请求不好。 如果我更改请求凭据并在标头中添加身份validation: string […]