List of usage examples for org.apache.commons.httpclient.params HttpMethodParams HTTP_CONTENT_CHARSET
String HTTP_CONTENT_CHARSET
To view the source code for org.apache.commons.httpclient.params HttpMethodParams HTTP_CONTENT_CHARSET.
Click Source Link
From source file:org.openo.nfvo.monitor.umc.util.APIHttpClient.java
public static String doPut(String uri, JSONObject jsonObj, String token) { String resStr = null;// ww w . j ava 2 s.c o m String requestBody = jsonObj.toString(); HttpClient htpClient = new HttpClient(); PutMethod putMethod = new PutMethod(uri); putMethod.addRequestHeader("Content-Type", "application/json"); putMethod.addRequestHeader("X-Auth-Token", token); putMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8"); putMethod.setRequestBody(requestBody); try { int statusCode = htpClient.executeMethod(putMethod); if (statusCode != HttpStatus.SC_OK) { return null; } byte[] responseBody = putMethod.getResponseBody(); resStr = new String(responseBody, "utf-8"); } catch (Exception e) { e.printStackTrace(); } finally { putMethod.releaseConnection(); } return resStr; }