HttpClient Post请求

 using (HttpClient httpClient = new HttpClient())
                    {
                        HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, URL);
                        request.Content = new StringContent(CommunicateTool.BuildUrl(data, Encoding.UTF8),
                                                            Encoding.UTF8,
                                                            "application/x-www-form-urlencoded");
                        var ar = httpClient.SendAsync(request).Result.Content.ReadAsStringAsync();
                        if (ar.Exception != null)
                        {
                            break;
                        }
                        if (string.IsNullOrEmpty(ar.Result))
                            break;
                        var jtoken = JToken.Parse(ar.Result);
                        if (jtoken.Value<int>("errCode") == 0)
                            result = true;
                    }
原文地址:https://www.cnblogs.com/ShenJA/p/13335393.html