一.Httpclient发送json请求 public String RequestJsonPost(String url){ String strresponse = null; try{ HttpClient hc = new DefaultHttpClient(); HttpPost hp = new HttpPost(url); JSONObject jsonParam = new JSONObject(); jsonPara…
public static JSONObject post(String url,JSONObject json){ HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); JSONObject response = null; try { StringEntity s = new StringEntity(json.toString()); s.setContentEncoding("UTF…
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.PostAsJson…