标签:reader 解析 token remember ons model des using add
[HttpPost]
[Route("api/order/PublicData/Add/")]
public int Add(users model)
{
string serviceAddress = "http://192.168.0.251:8887/aaa/user/cms";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
int[] roleIds = new int[] { 1 };
request.Method = "PUT";
request.ContentType = "application/json;charset=UTF-8";
request.Headers.Add("Access-Token", model.token.ToString());
//string strContent = @"{ ""roleIds"": ""123456"",""rememberMe"": ""false"",""userName"": ""jielio""}";
string strContent = @"{ ‘roleIds‘: " + "[1]" + ", ‘loginName‘: ‘" + model.loginName + "‘, ‘password‘: ‘" + model.password + "‘, ‘userName‘: ‘" + model.userName + "‘, ‘phonenumber‘: ‘" + model.phonenumber + "‘, ‘status‘: ‘" + model.status + "‘}";
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();
//JObject jo = JObject.Parse(retString);
//解析josn
user jo1 = JsonConvert.DeserializeObject<user>(retString);
//return jo1;
return jo1.data;
}
标签:reader 解析 token remember ons model des using add
原文地址:https://www.cnblogs.com/tfeblog/p/10931281.html