我正在尝试使用GeoServer Rest在层上实现Get、Post、Put和Delete操作。
我能够成功地实现Get、Put和Delete方法。
但是,当我试图在层上实现Post方法时,GeoServer返回状态代码: 405,即方法未找到。
这是我的代码:
public async Task<IActionResult> PostLayer(string layerName)
{
var authValue = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("admin:geoserver")));
try
{
var client = new HttpClient()
{
DefaultRequestHeaders = { Authorization = authValue }
};
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.BaseAddress = new Uri("http://localhost:8080");
var stringContent = new StringContent(@"C:\Users\i2vsys\Desktop\test.kml");
var response = await client.PostAsync($"/geoserver/rest/layers/{layerName}",stringContent);
response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync();
return Ok(stringResponse);
}
catch (HttpRequestException ex)
{
return BadRequest(ex.Message);
}
}但是根据GeoServer api文档,它有POST方法。所以,问题肯定在我这一边,我找不到。我也曾见过其他人的质疑,但这些解决方案对我无效。
任何帮助都将不胜感激。
发布于 2017-05-22 14:32:00
当我查看层文档时,我没有看到对POST请求的引用。你希望一个帖子能做些什么?
要创建一个新层,首先要使用创建一个新的DataStore,如示例中所述。使用一些东西,比如:
curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip"
--data-binary @roads.zip http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/file.shphttps://stackoverflow.com/questions/44113503
复制相似问题