C# WebClient 发送post请求带参数
string param= "参数1";
string param2= "参数2";
string[,] sensorNumList = new string[3,5] {
{
"0011", "0012", "0013", "0014", "0015"},{
"0016", "0017", "0018", "0019", "001a"},{
"001b", "001c", "001d", "001e", "001f"}};
string url = "";
string paramList = "{\"param1\":" + param+ ",\"param2\":\"" + param2+ "\,\"sensorNumList \":\"" + sensorNumList + "\"}";byte[] postData = Encoding.UTF8.GetBytes(paramList );WebClient webClient = new WebClient();webClient .Headers.Add("Content-Type", "application/json"); webClient .Headers.Add("ContentLength", postData.Length.ToString());byte[] responseData = client.UploadData(url, "POST", postData); Encoding.UTF8.GetString(responseData);