public void PostData(Employee employee) { if(employee!=null) { string url = "https://api.lob.com/v1/postcards"; string jsonData = "{ \"name\" : \"ramu\", \"from\":\"sanjeev\", \"to\":\"Rajeev\",\"front\":\"file:C:\\Users\\hb1\\Desktop\\New folder\\300.png\",\"back\":\"\",\"full_bleed\":1, \"message\":\"hi how are you man\" }"; try { WebRequest request = WebRequest.Create(url); if (request != null) { request.Method = "POST"; request.Timeout = 20000; // ServicePointManager.DefaultConnectionLimit = 1000; request.Credentials = new NetworkCredential("*********************", ""); System.Net.ServicePointManager.Expect100Continue = false; //cookie container of previous request using (Stream s = request.GetRequestStream()) { using (StreamWriter sw = new System.IO.StreamWriter(s)) { sw.Write(jsonData); } } using (Stream s1 = request.GetResponse().GetResponseStream()) { using (StreamReader sr = new StreamReader(s1)) { string jsonResponse = sr.ReadToEnd(); } } } } catch (Exception ex) { Response.Write(ex.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)