0
我有捲曲的請求:翻譯捲曲restsharp
curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @C:\nyc_khr.zip http://localhost:9090/geoserver/rest/workspaces/nyc_roads/datastores/roads/file.shp
我需要做類似上面的要求,但使用C#代碼的我
例如:
RestClient client = new RestClient(URL)
{
Authenticator = new HttpBasicAuthenticator("admin", "geoserver")
};
var data = File.ReadAllBytes(somePath);
string url = @"rest/workspaces/nyc_roads/datastores/roads/finalas.shx";
var request = new RestRequest(url, Method.PUT);
request.AddHeader("Content-Type", "application/zip");
request.AddFile("finalik.zip", data, "finalik.zip", "application/zip");
var response = client.Execute(request);
var res = response.ContentType;
你有什麼問題/錯誤? – NikolaiDante
我從服務器「無法確定格式,嘗試設置內容類型標題」。但如果我使用cUrl,它工作正常。 \ –
在您的示例中,我看到URL不匹配 - cURL指向'roads/file.shp',但RestSharp指向'roads/finalas.shx'。這可能是原因,還是僅僅是一些示例代碼? –