接口

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
            request.Method = "POST";
            request.ContentType = "application/json";
            request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
            byte[] data = Encoding.UTF8.GetBytes(postDataStr);
            string bytestring = Encoding.UTF8.GetString(data);
            Stream os = null;
            try
            {
                request.ContentLength = data.Length;
                os = request.GetRequestStream();
                os.Write(data, 0, data.Length);

                HttpWebResponse wr = (HttpWebResponse)request.GetResponse();
                Stream receiveStream = wr.GetResponseStream();
                StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
                string content = reader.ReadToEnd();

                return content;
            }
            catch (Exception es)
            {
                //MessageBox.Show(es.InnerException.Message.ToString());
                return "";
            }

  

posted @ 2016-03-28 10:58  小爆脾气  阅读(115)  评论(0编辑  收藏  举报