using System.Text; using log4net; using Newtonsoft.Json; namespace Common.Util; public static class HttpUtil { private static readonly HttpClient httpClient = new HttpClient(); private static readonly ILog Log = LogManager.GetLogger(typeof(HttpUtil)); public static async void SendPostRequest(T data, string url) { try { string jsonStr = JsonConvert.SerializeObject(data); var content = new StringContent(jsonStr, Encoding.UTF8, "application/json"); HttpResponseMessage response = await httpClient.PostAsync(url, content); if (response.IsSuccessStatusCode) { await response.Content.ReadAsStringAsync(); } } catch (Exception e) { Log.Info("HttpUtil SendPostRequest Error:"+e.StackTrace); } } }