Ejemplo n.º 1
0
        public string GetIntenctroy()
        {
            var    entity = new RequestInventoryApi();
            string url    = "http://www.hozest.com.cn:30003/WebApi/Values/GetInventoryInfo";
            //string url = "http://localhost:16566/WebApi/Values/GetInventoryInfo";
            string         json     = "";
            Encoding       encoding = Encoding.UTF8;
            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "post";
            request.Headers.Add("userName", "wudaoshangcheng");
            request.Headers.Add("passWord", "wd123456");
            request.Headers.Add("accessToken", "Hhum0fYEXMUKSb2QWUi0");
            //request.KeepAlive = true;
            request.Accept      = "text/html, application/xhtml+xml, */*";
            request.ContentType = "application/json;charset=utf-8";
            //entity.PlatformMerchantCode = new List<string>() { "4897086340269", "4903367304032", "1006010001" };
            entity.PageNum  = 1;
            entity.PageSize = 200;
            var signstr = string.Format("{0}Hozest88582", JsonConvert.SerializeObject(entity));

            var rsignstrMd5 = _utilManager.MD5Encrypt(signstr);

            entity.SecretKey = rsignstrMd5;

            byte[] buffer = encoding.GetBytes(JsonConvert.SerializeObject(entity));
            request.ContentLength = buffer.Length;

            request.GetRequestStream().Write(buffer, 0, buffer.Length);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                json = reader.ReadToEnd();
            }
            return(json);
        }