public static string Post(string url, string paramData, Encoding encoding) { string result = ""; if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return(true); }); } try { var wc = new WebClient(); if (string.IsNullOrEmpty(wc.Headers["Content-Type"])) { wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); } wc.Encoding = encoding; result = wc.UploadString(url, "POST", paramData); } catch (Exception ex) { LogsHelper.WriteErrorLog(ex); } return(result); }
public static T DeserializeObject <T>(this string input) { try { return(JsonConvert.DeserializeObject <T>(input)); } catch (Exception ex) { LogsHelper.WriteErrorLog(ex, ""); return(default(T)); } }