| | |
| | | String result = ""; |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | HttpPatch httpPatch = new HttpPatch(url); |
| | | CloseableHttpResponse response = null; |
| | | httpPatch.setHeader("Content-type", "application/json"); |
| | | httpPatch.setHeader("Charset", "utf-8"); |
| | | httpPatch.setHeader("Accept", "application/json"); |
| | |
| | | try { |
| | | StringEntity data = new StringEntity(params, "utf-8"); |
| | | httpPatch.setEntity(data); |
| | | HttpResponse response = httpClient.execute(httpPatch); |
| | | response = httpClient.execute(httpPatch); |
| | | HttpEntity entity = response.getEntity(); |
| | | result = EntityUtils.toString(entity); |
| | | } catch (Exception e) { |
| | | result = "{\"status\":\"1\",\"error\":\"" + e.getMessage() + "\"}"; |
| | | }finally { |
| | | try { |
| | | httpClient.close(); |
| | | if (response != null) { |
| | | response.close(); |
| | | } |
| | | } catch (IOException var22) { |
| | | var22.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | |
| | | while (true) { |
| | | CloseableHttpClient client = HttpClients.createDefault(); |
| | | HttpPost httpPost = new HttpPost(url); |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | httpPost.addHeader("Content-type", "application/json"); |
| | | httpPost.addHeader("Charset", "utf-8"); |
| | |
| | | |
| | | StringEntity data = new StringEntity(params, "utf-8"); |
| | | httpPost.setEntity(data); |
| | | HttpResponse response = client.execute(httpPost); |
| | | response = client.execute(httpPost); |
| | | HttpEntity resEntity = response.getEntity(); |
| | | result = EntityUtils.toString(resEntity); |
| | | return result; |
| | |
| | | } catch (InterruptedException e1) { |
| | | result = "{\"status\":\"1\",\"errors\":\"" + e1.getMessage() + "\"}"; |
| | | } |
| | | }finally { |
| | | try { |
| | | client.close(); |
| | | if (response != null) { |
| | | response.close(); |
| | | } |
| | | } catch (IOException var22) { |
| | | var22.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return result; |