HttpClient post json,可以是数组

var json = JsonConvert.SerializeObject(obj);
StringContent theContent = new StringContent(json, Encoding.UTF8, "application/json");
var r = client.PostAsync(url, theContent).Result.Content.ReadAsStringAsync().Result;

 

有简单一点的方法

client.PostAsJsonAsync(url, new {});
需要引入System.Net.Http.Formatting.dll
posted @ 2015-11-25 12:57  czcz1024  阅读(1418)  评论(0编辑  收藏  举报