public string Get() { string url = "http://localhost:16566/WebApi/Values/ImportOrder"; string json = ""; Encoding encoding = Encoding.UTF8; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "post"; request.Headers.Add("userName", "wudaoshangcheng"); request.Headers.Add("passWord", "wd123456"); request.Headers.Add("accessToken", "Hhum0fYEXMUKSb2QWUi0"); request.KeepAlive = true; request.Accept = "text/html, application/xhtml+xml, */*"; request.ContentType = "application/json;charset=utf-8"; request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"; var orderInfoList = new OrderInfoListClient(); orderInfoList.xmOrderInfoClientList = new List <XMOrderInfoClient>(); //for (var i = 0; i < 1; i++) //{ // var entity = new XMOrderInfoClient(); // entity.XM_OrderInfoProductDetails = new List<XMOrderInfoProductDetailsClient>(); // entity.PlatformTypeId = 508; // entity.OrderCode = "SH201904124521771121111" + i; // entity.NickID = 77; // entity.OrderStatus = "已付款"; // entity.RealName = "王瑜"; // entity.PaymentNo = "41697455477425"; // entity.OrderSeqNo = "74485411212121"; // entity.Source = "02"; // entity.IdentityCard = "666554558855"; // entity.CreateDate = DateTime.Now; // entity.OrderInfoCreateDate = Convert.ToDateTime("2019-04-12T18:24:48+08:00"); // entity.PayDate = Convert.ToDateTime("2019-04-12T18:24:48+08:00"); // entity.WantID = "王瑜"; // entity.ProductPrice = (decimal)379.9; // entity.DistributePrice = (decimal)20.00; // entity.ProductPromotion = 0; // entity.OrderPromotion = 0; // entity.OrderPrice = (decimal)399.9; // entity.PayPrice = (decimal)379.9; // entity.ReceivablePrice = (decimal)379.9; // entity.DistributeMethod = "仓库配送"; // entity.FullName = "wangyu"; // entity.Mobile = "13567424734"; // entity.Province = "浙江省"; // entity.City = "嘉兴市"; // entity.County = "海盐县"; // entity.DeliveryAddress = "西塘桥街道外塘路666号万通安达"; // entity.SourceType = "接口导入"; // entity.FinancialAudit = false; // entity.IsScalping = false; // entity.IsAudit = false; // entity.IsEnable = false;//是否删除 // entity.IsCashBack = false;//是否返现 // entity.IsSentGifts = false;//是否已发赠品 // entity.IsEvaluate = false;//是否赔付 // entity.IsOurOrder = true; // entity.CreateID = 7; // entity.UpdateID = 7; // entity.CreateDate = DateTime.Now; // entity.UpdateDate = DateTime.Now; // //for (var j = 0; j < 1; j++) // //{ // var entityDetails = new XMOrderInfoProductDetailsClient(); // entityDetails.PlatformMerchantCode = "1002010001"; // entityDetails.ProductName = "资生堂洗颜专科洗面奶120g*2 "; // //entityDetails.TManufacturersCode = dic[j]; // entityDetails.SalesPrice = decimal.Parse("379.9"); // entityDetails.ProductNum = 2; // entity.XM_OrderInfoProductDetails.Add(entityDetails); // //} // orderInfoList.xmOrderInfoClientList.Add(entity); //} //var clientOrderList = orderInfoList.xmOrderInfoClientList; //var jsonParas = JsonConvert.SerializeObject(orderInfoList); var jsonParas = _utilManager.ReadTxtContent(); byte[] buffer = encoding.GetBytes(jsonParas); request.ContentLength = buffer.Length; request.GetRequestStream().Write(buffer, 0, buffer.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { json = reader.ReadToEnd(); } return(json); }