1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//地址 string _url = "https://www.dXXXayup.ink/api/User/Login"; //json参数 string jsonParam = "{ phonenumber:\"18665885202\",pwd:\"tsp\"}"; var request = (HttpWebRequest)WebRequest.Create(_url); request.Method = "POST"; request.ContentType = "application/json;charset=UTF-8"; byte[] byteData = Encoding.UTF8.GetBytes(jsonParam); int length = byteData.Length; request.ContentLength = length; Stream writer = request.GetRequestStream(); writer.Write(byteData, 0, length); writer.Close(); var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd(); MessageBox.Show(responseString.ToString()); |