url upload data

HttpPost httpPost = new HttpPost(url); //创建post
httpPost.addHeader("AUTH_TOKEN", token); //认证

ObjectMapper mapper = new ObjectMapper();
String jsonModel = mapper.writeValueAsString(obj); // create json content from obj(model).
StringEntity entity = new StringEntity(jsonModel, "utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);

CloseableHttpClient httpclient = HttpClients.createDefault(); //client post
httpResponse = httpclient.execute(httpPost)

posted @ 2015-11-30 11:43  吴某1  阅读(243)  评论(0编辑  收藏  举报