C# post 提交 application/json 类型数据
来源:互联网 发布:校园不良网络借贷ppt 编辑:程序博客网 时间:2024/06/06 01:47
public static string PostJson(string url, string jsonParam,string encode)
{
string strURL = url;
System.Net.HttpWebRequest request;
request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
request.Method = "POST";
request.ContentType = "application/json;charset="+encode.ToUpper();
string paraUrlCoded = jsonParam;
byte[] payload;
payload = System.Text.Encoding.GetEncoding(encode.ToUpper()).GetBytes(paraUrlCoded);
request.ContentLength = payload.Length;
Stream writer = request.GetRequestStream();
writer.Write(payload, 0, payload.Length);
writer.Close();
System.Net.HttpWebResponse response;
response = (System.Net.HttpWebResponse)request.GetResponse();
System.IO.Stream s;
s = response.GetResponseStream();
string StrDate = "";
string strValue = "";
StreamReader Reader = new StreamReader(s, Encoding.GetEncoding(encode.ToUpper()));
while ((StrDate = Reader.ReadLine()) != null)
{
strValue += StrDate + "\r\n";
}
return strValue;
}
{
string strURL = url;
System.Net.HttpWebRequest request;
request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
request.Method = "POST";
request.ContentType = "application/json;charset="+encode.ToUpper();
string paraUrlCoded = jsonParam;
byte[] payload;
payload = System.Text.Encoding.GetEncoding(encode.ToUpper()).GetBytes(paraUrlCoded);
request.ContentLength = payload.Length;
Stream writer = request.GetRequestStream();
writer.Write(payload, 0, payload.Length);
writer.Close();
System.Net.HttpWebResponse response;
response = (System.Net.HttpWebResponse)request.GetResponse();
System.IO.Stream s;
s = response.GetResponseStream();
string StrDate = "";
string strValue = "";
StreamReader Reader = new StreamReader(s, Encoding.GetEncoding(encode.ToUpper()));
while ((StrDate = Reader.ReadLine()) != null)
{
strValue += StrDate + "\r\n";
}
return strValue;
}
0 0
- C# post 提交 application/json 类型数据
- application/json 四种常见的 POST 提交数据方式
- application/json 四种常见的 POST 提交数据方式
- yii2-结合angularjs实现application/json的post数据提交
- application/json 四种常见的 POST 提交数据方式
- application/json 四种常见的 POST 提交数据方式
- application/json 四种常见的 POST 提交数据方式
- application/json 四种常见的 POST 提交数据方式
- application/json 四种常见的 POST 提交数据方式
- application/json 四种常见的 POST 提交数据方式
- POST提交JSON数据
- C# Post Json数据
- php模拟post提交提交json数据
- fetch post application/json 传递复杂类型
- C# POST,GET 提交数据
- C# Post请求json数据
- 通过Ajax进行POST提交JSON类型的数据到SpringMVC Controller的方法
- CURL模拟POST提交JSON数据
- 正确遍历删除List中的元素(着重看iterator方式)
- Topic Model
- Win 10安装Cisco System VPN Client报错27850 Bug解决
- N-Gram学习笔记
- 文本分类的数据预处理相关知识介绍
- C# post 提交 application/json 类型数据
- 十三种常用的数据挖掘的技术&…
- 18-每天一个Linux命令 locate
- 我理解的信息论——自信息、熵…
- 信息论中的MI(互信息公式)
- 互信息的理解
- c++字符串详解(转)
- 浅谈JavaScript中的五种为事件指定处理程序的方式
- C++字符串总结