HttpClient使用

HttpClient httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(8);

//发送参数
string  jsonTemp="{
    \"template_id_short\":\"TM00015\"
}";
HttpContent httpContent = new StringContent(jsonTemp);

var response = await httpClient.PostAsync("http://www.qq.com", httpContent);
if (!response.IsSuccessStatusCode)
{
return new Result("发送数据失败");
}
//返回消息
string backResult = await response.Content.ReadAsStringAsync();

你可能感兴趣的:(C#,http,c#)