using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace WIDESEA_WCS { public class Request { /// /// post请求 /// /// 参数 /// 路径 /// public static string RequestData(string postData, string url = "") { string reponse = string.Empty; try { //string tmp = ""; //if (null != postData) // tmp = JsonConvert.SerializeObject(postData); byte[] param = Encoding.UTF8.GetBytes(postData); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/json"; request.GetRequestStream().Write(param, 0, param.Length); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream stream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(stream); string webResponse = streamReader.ReadToEnd(); reponse = webResponse; } } catch (Exception ex) { reponse = ex.Message; } return reponse; } } }