public void readAndSaveBarnamehToDB(long barnameh_no, int cycleNumber) { try { Uri uri; uri = new Uri(this.v_urlFindBillOfLading); trainBillOfLadingsJsonModel[] trainBillOfLadingsListJson = null; WebRequest webRequest = WebRequest.Create(uri); webRequest.Proxy = null; webRequest.Method = "POST"; webRequest.Headers.Add("Cache-Control", "no-cache"); webRequest.Headers.Add("Cookie", "__RequestVerificationToken=Gm4hoEFS8RkxaSfJxpaeorLztRy6-rfjyKm1pRyPYQP-4dGSPAKrHWG62K3vaJOz_k7xEJBWigJHetij4ID_TmbP-27KPhaINnSun-IMnZc1;"); webRequest.ContentType = "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"; // "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"__RequestVerificationToken\"\r\n\r\nGJKWN0U0ndGyC5fAKEdhhosJMhpjLmtfvNIieri7YR8Q37_BUn-lmEg6ucZPrWPefAcxG1-5TPMtYPZsa6fFIigJBBICLcfUlMrufrpIV6U1\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" string postData; postData = "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"__RequestVerificationToken\"\r\n\r\nGJKWN0U0ndGyC5fAKEdhhosJMhpjLmtfvNIieri7YR8Q37_BUn-lmEg6ucZPrWPefAcxG1-5TPMtYPZsa6fFIigJBBICLcfUlMrufrpIV6U1\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW" + "\r\nContent-Disposition: form-data; name=\"barnameh_no\"\r\n\r\n" + barnameh_no.ToString() + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"; byte[] formData = Encoding.UTF8.GetBytes(postData); Stream streamRequest = webRequest.GetRequestStream(); streamRequest.Write(formData, 0, formData.Length); streamRequest.Flush(); streamRequest.Close(); WebResponse webResponse = webRequest.GetResponse(); if (webResponse != null) { string result; using (StreamReader rd = new StreamReader(webResponse.GetResponseStream())) { result = rd.ReadToEnd(); } webResponse.Close(); trainBillOfLadingsListJson = Newtonsoft.Json.JsonConvert.DeserializeObject <trainBillOfLadingsJsonModel[]>(result); if (trainBillOfLadingsListJson != null) { using (var entityLogistic = new Model.logisticEntities()) { foreach (trainBillOfLadingsJsonModel billOfLading in trainBillOfLadingsListJson) { if (billOfLading.Train_No.HasValue) { PWS0.trainBarryBillOfLadings bill = new trainBarryBillOfLadings(); bill.sb_saveToDB(billOfLading, billOfLading.Train_No.Value, null, cycleNumber, "findBariWagon"); } } } } } } catch (Exception ex) { } }