HttpClient 传参调用

public iflow_result iFlowPost(V_Flow flow, string account)
{

string paramsJsonStr = JsonConvert.SerializeObject(flow);
string sysid = _settings.iFlow_sysid;
string syspwd = _settings.iFlow_syspwd;
string userId = account;
string ApiAddress = _settings.iFlow_API;
HttpContent content = new StringContent(paramsJsonStr);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
//var ContentType = new MediaTypeHeaderValue("application/json");
//ContentType.CharSet = "UTF-8";
//content.Headers.ContentType = ContentType;
content.Headers.Add("sysid", sysid);
content.Headers.Add("syspwd", syspwd);
content.Headers.Add("userId", userId);
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.Timeout = new TimeSpan(0, 0, 0, 0, 30000);
HttpResponseMessage response = client.PostAsync(ApiAddress, content).Result;
string result = response.Content.ReadAsStringAsync().Result;
var bck = JsonConvert.DeserializeObject<iflow_result>(result);
if (bck.success == true)
{
#region log

#endregion
}
return bck;

}

posted on 2020-07-22 13:45  gfbppy  阅读(478)  评论(0编辑  收藏  举报

导航