远程读取接口的数据

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://XXX/service/Service.ashx?token={A50F6425-D6E7-458D-992A-AB61B3F8CF9B}&action=plancollege&pageindex=1&pagesize=30&classid=" + classid + "&orderid=" + orderid + "&levelid=" + levelid + "&collegename=" + sCollege + "&provinceid=" + pro);
            request.Method = "GET";
            request.ContentType = "text/html;charset=UTF-8";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
            string retString = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();

转载于:https://www.cnblogs.com/superMay/p/4800102.html

你可能感兴趣的:(远程读取接口的数据)