我想在C#中进行以下curl调用:
curl "http://localhost:8983/solr/update/extract?literal.id=doc1&commit=true" -F "[email protected]"
我发现我应该使用WebRequest类,但是我仍然不确定如何处理这一部分:
-F "[email protected]"
最佳答案
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx中的代码片段显示了如何使用WebRequest类发送POST数据:
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("http://localhost:8983/solr/update/extract?literal.id=doc1&commit=true");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "[email protected]";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
关于c# - 带标志的C#中的cURL调用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12398541/