public String sendLogs(String data) throws Exception{
String result = null;
CloseableHttpClient httpClient = HttpClients.createDefault();
try{
HttpPost httpPost = new HttpPost(url);
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("xtid",new StringBody(xtid, ContentType.APPLICATION_JSON))
.addPart("logsXml",new StringBody(data,ContentType.APPLICATION_JSON))
.build();
httpPost.setEntity(reqEntity);
CloseableHttpResponse response = httpClient.execute(httpPost);
try{
HttpEntity resEntity = response.getEntity();
if(resEntity != null){
result = IOUtils.toString(resEntity.getContent(),"utf-8");
}
EntityUtils.consume(resEntity);
return result;
}finally {
response.close();
}
}finally {
httpClient.close();
}
}