其他分享
首页 > 其他分享> > HttpClient 使用案例

HttpClient 使用案例

作者:互联网

get
HttpClient httpClient = new HttpClient(); var request = new HttpRequestMessage() { Content = null, Method = HttpMethod.Get, RequestUri = new Uri("https://oapi.dingtalk.com/gettoken?appkey=&appsecret=") }; var result = await httpClient.SendAsync(request);
form post

string url = "http://openapi.italent.link/OAuth/Token"; var values = new List<KeyValuePair<string, string>>(); values.Add(new KeyValuePair<string, string>("grant_type", "client_credentials")); values.Add(new KeyValuePair<string, string>("app_id", "908")); values.Add(new KeyValuePair<string, string>("tenant_id", "410034")); values.Add(new KeyValuePair<string, string>("secret", "testsecretxxxxxxxxxxxxxxxxxx908")); var formdata = new FormUrlEncodedContent(values); var result = await httpClient.PostAsync(url, formdata);

 

标签:KeyValuePair,案例,Add,values,使用,var,new,httpClient,HttpClient
来源: https://www.cnblogs.com/liuqiyun/p/16169549.html