这是我这里HTTP串口打开的数据,msg是我要传入的数据!
{"code":0,"msg":"请输入正确的参数","time":"1635835468","data":null}
然后我的代码这么写,再打开http并没有什么变化!
想把textbox上的数据传过去
string serviceAddress = "我的网址";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
request.Method = "POST";
request.ContentType = "application/json";
string strContent = @"{ ""msg"": ""没什么""}";
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
{
dataStream.Write(strContent);
dataStream.Close();
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd();
//解析josn
JObject jo = JObject.Parse(retString);
textBox11.Text = (jo["time"].ToString());