using System; using RestSharp; namespace Tool { public class HttpUtil { /// /// 提交json字符 /// /// /// /// public static string PostJson(string url, object obj) { try { var client = new RestClient(url); var request = new RestRequest(); request.AddHeader("Content-Type", "application/json"); request.Method = Method.Post; request.Timeout = TimeSpan.FromMinutes(2); request.AddBody(obj, ContentType.Json); var response = client.Execute(request); return response.Content; } catch (Exception e) { ILogNetFactory.GetLogNet.WriteError(e.Message); return e.Message; } } } }