postman x-www-form-urlencoded .net 方式

 

using WebClient = System.Net.WebClient;

string sSendStr = "message=" + JsonHelper.SerializeObject(sendObj);
//string sResult = HttpHelper.WebApiHttpHelper.Post(System.Configuration.ConfigurationManager.AppSettings["TruckSysApiUrl"], sSendStr, false, true, BondexCas.UserInfo.Token);

WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
webClient.Headers.Add("Token", BondexCas.UserInfo.Token);
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] postData = Encoding.UTF8.GetBytes(sSendStr);
byte[] responseData = webClient.UploadData(System.Configuration.ConfigurationManager.AppSettings["TruckSysApiUrl"], "POST", postData);
string sResult = Encoding.UTF8.GetString(responseData);

 

posted @ 2021-12-09 14:33  msikruby  阅读(137)  评论(0编辑  收藏  举报