/// <summary> /// 通过链接调用方法 /// </summary> /// <param name="Url">链接</param> /// <param name="postDataStr">传入参数</param> /// <returns></returns> public string HPost(string Url, string postDataStr) { string retString = ""; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr); Stream myRequestStream = request.GetRequestStream(); StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312")); myStreamWriter.Write(postDataStr); myStreamWriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); retString = myStreamReader.ReadToEnd(); myStreamReader.Close(); myResponseStream.Close(); return retString; } protected void Button1_Click(object sender, EventArgs e) { string SYSSerialNo = "SYS20170315003"; string item = "181119071001378"; string token = "b9cddf7dcc584baa94448b71562c9f44"; string PostMsg = "{\"head\":{\"transCode\":\"P1007\",\"transId\":\"20180710105959JEj5\"},\"body\":{\"sys\":\"" + SYSSerialNo + "\",\"order_sn\":\"" + item + "\"}}"; string Url = "https://a.asus.com.cn/channel/v1.0/SYCBD/PPQybOrder?appid=WHlejuMgmW9S&token=" + token; //获取接口返回值 string RequestMsg = HPost(Url, PostMsg); JObject jo = (JObject)JsonConvert.DeserializeObject(RequestMsg); }