我有这个hardware来自Patlite, 这个硬件有一个HTTP命令控制功能,例如,如果我复制网址“http://192.168.10.1/api/control?alert=101002”在我的电脑中镀铬,它将根据需要激活硬件。c#如何发送HTTP命令,因为这 - http://192.168.10.1/api/control?alert=101002
我想从我的代码发送命令。
我想这个代码没有运气:
System.Net.ServicePointManager.Expect100Continue = false;
WebRequest request = WebRequest.Create("http://10.0.22.222/api/control");
request.Method = "post";
request.ContentType = "application/x-www-form-urlencoded";
string postData = "alert=101002";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
WebResponse response = request.GetResponse();
感谢
“我试过这段代码没有运气”发生了什么事? – Oscar