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)

你可能感兴趣的:(url upload data)