您的位置:首页 > 理论基础 > 计算机网络

httpclient通过post提交到webapi

2015-05-06 16:43 218 查看
var client = new HttpClient();
var url = BASConfig.Instance.SiteSettingsModule.SyncWorkLogAppUrl;
var paramlist = new List<KeyValuePair<string, string>>();
paramlist.Add(new KeyValuePair<string, string>("CompanyId", bodyId.ToString()));
paramlist.Add(new KeyValuePair<string, string>("UserId", loginId.ToString()));
paramlist.Add(new KeyValuePair<string, string>("year", Date.Year.ToString()));
paramlist.Add(new KeyValuePair<string, string>("month", Date.Month.ToString()));
paramlist.Add(new KeyValuePair<string, string>("day", Date.Day.ToString()));
paramlist.Add(new KeyValuePair<string, string>("summary", content));
var result = client.PostAsync(new Uri(url), new FormUrlEncodedContent(paramlist)).Result;
return result.Content.ReadAsStringAsync().Result;

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: