C# Httpclient

来源:互联网 发布:龙虾不会自然死亡 知乎 编辑:程序博客网 时间:2024/06/03 04:59

using System.Net.Http;
using System.Net.Http.Headers;


            HttpClient client =  new HttpClient();


            string guid = "XXXXXXXXXXXXX";


            var requestURL = "http://mkcloud.XXXXXXXXXXXX";
            var req = Newtonsoft.Json.JsonConvert.SerializeObject(new
            {
                token = "XXXXXXXXXXXXXXXX",
                projectId = XX,
                dpguid = guid
            });
            var contentStr = string.Empty;


            HttpResponseMessage response = null;
            response = client.PostAsync(requestURL, new StringContent(req)).Result;
            if (response != null)
            {
                    var resultValue = response.Content.ReadAsStringAsync().Result;
                    string strResponse = HttpUtility.UrlDecode(resultValue.ToString());
            }

原创粉丝点击