LOGGER.error(String.format("Failed to execute the redirected PUT request to upload segment to webhdfs: %s. " + "Expected response code 201, but get %s. Response: %s", redirectedReqString, redirectedResponseCode, redirectedReq.getResponseBodyAsString()));
@Ignore @Test public void testRestAPI() throws IOException { HttpClient client = new HttpClient(); // To be avoided unless in debug mode Credentials defaultcreds = new UsernamePasswordCredentials("admin", "111111"); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); PutMethod method = new PutMethod("http://localhost:8080/agent/api/36"); final HttpMethodParams params = new HttpMethodParams(); params.setParameter("action", "approve"); method.setParams(params); final int i = client.executeMethod(method); System.out.println(method.getResponseBodyAsString()); } }
protected String executePut(final String uri) throws NeutronRestApiException { try { validateCredentials(); } catch (NeutronInvalidCredentialsException e) { throw new NeutronRestApiException("Invalid credentials!", e); } NeutronRestFactory factory = NeutronRestFactory.getInstance(); NeutronRestApi neutronRestApi = factory.getNeutronApi(PutMethod.class); PutMethod putMethod = (PutMethod) neutronRestApi.createMethod(url, uri); try { String encodedCredentials = encodeCredentials(); putMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials); neutronRestApi.executeMethod(putMethod); if (putMethod.getStatusCode() != HttpStatus.SC_OK) { String errorMessage = responseToErrorMessage(putMethod); putMethod.releaseConnection(); s_logger.error("Failed to update object : " + errorMessage); throw new NeutronRestApiException("Failed to update object : " + errorMessage); } return putMethod.getResponseBodyAsString(); } catch (NeutronRestApiException e) { s_logger.error("NeutronRestApiException caught while trying to execute HTTP Method on the Neutron Controller", e); throw new NeutronRestApiException("API call to Neutron Controller Failed", e); } catch (IOException e) { throw new NeutronRestApiException("Failed to load json response body", e); } finally { putMethod.releaseConnection(); } }
System.out.println("Response status code: " + result); System.out.println("Response body: "); System.out.println(put.getResponseBodyAsString()); } finally {
System.out.println("Response status code: " + result); System.out.println("Response body: "); System.out.println(put.getResponseBodyAsString()); } finally {
/** * put-method for rest interface to couchdb * @author daemonmidi@gmail.com * @since version 2.5 * @param url * @return string responesBody */ private String sendPut(String url, String requestBody){ String responseBody = ""; org.apache.commons.httpclient.HttpClient client = new HttpClient(); client.getParams().setParameter("http.useragent", "jbrofuzz"); PutMethod method = new PutMethod(url); // method.getParams().setParameter("retryHandler", new DefaultHttpRequestRetryHandler(3, false)); if (requestBody.length() > 0 ) method.setRequestBody(requestBody); try { responseBody = method.getResponseBodyAsString(); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally{ client.getHttpConnectionManager().closeIdleConnections(0); } return responseBody; }
String response = put.getResponseBodyAsString();
String response = put.getResponseBodyAsString(); responseHolder.put(InvocationResult.STATUS, Integer.valueOf(statusCode));
public ApplicationServerManagerResult deploy(String appPath, InputStream is, int size) throws IOException { try { deploy.setQueryString(buildPathQueryArgs(appPath)); deploy.setContentChunked(true); deploy.setRequestEntity(new InputStreamRequestEntity(is)); client.executeMethod(deploy); return parseResult(deploy.getResponseBodyAsString()); } finally { deploy.releaseConnection(); deploy.setPath(deployPath); } }
int updateResponseStatus = httpUpdateClient.executeMethod(putMethod); logger.info("SCIM update user operation returned with response code: " + updateResponseStatus); String updateResponse = putMethod.getResponseBodyAsString(); if (logger.isDebugEnabled()) { logger.debug("SCIM update user response: " + updateResponse);
logger.info("SCIM update group operation returned with response code: " + updateResponseStatus); String updateResponse = putMethod.getResponseBodyAsString(); if (logger.isDebugEnabled()) { logger.debug("SCIM update group response: " + updateResponse);
String response = putMethod.getResponseBodyAsString();