public static string PostResponse(string url, string postData)
{
try
{
if (url.StartsWith("https"))
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
string EncryModel = postData;
HttpContent httpContent = new StringContent(EncryModel);
HttpClient httpClient = new HttpClient();
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
string result = response.Content.ReadAsStringAsync().Result;
return result;
}
else
{
Power.Log.Logging4net.WriteError(null, "PostResponse 请求数据失败:" + response.Content.ReadAsStringAsync().Result);
}
}
catch (Exception e)
{
Power.Log.Logging4net.WriteError(e, "PostResponse url" + url + "------------" + postData);
}
return null;
}