Source:
public ResponseEntity<?> handleWithUserPasswordAndReturnType(MotechEvent motechEvent) { Map<String, Object> parameters = motechEvent.getParameters(); final String url = String.valueOf(parameters.get(SendRequestConstants.URL)); Object requestData = parameters.get(SendRequestConstants.DATA); String username = String.valueOf(parameters.get(SendRequestConstants.USERNAME)); String password = String.valueOf(parameters.get(SendRequestConstants.PASSWORD)); boolean checkbox = (boolean) parameters.get(SendRequestConstants.CHECKBOX); LOGGER.info(String.format("Posting Http request -- Url: %s, Data: %s", url, String.valueOf(requestData))); HttpEntity<Object> entity = new HttpEntity<>(requestData); RestTemplate restTemplate; if (StringUtils.isNotBlank(username) || StringUtils.isNotBlank(password)) { restTemplate = new RestTemplate(usernamePasswordRequestFactory( username, password)); } else { restTemplate = basicRestTemplate; } if (!checkbox) { final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); HttpClient httpClient; httpClient = HttpClientBuilder.create().disableRedirectHandling().build(); factory.setHttpClient(httpClient); restTemplate.setRequestFactory(factory); } int retryCount = 1; long retryInterval = 0; if (parameters.get(EventDataKeys.RETRY_COUNT) != null) { retryCount = (int) parameters.get(EventDataKeys.RETRY_COUNT); } if (parameters.get(EventDataKeys.RETRY_INTERVAL) != null) { retryInterval = (long) parameters.get(EventDataKeys.RETRY_INTERVAL); } return checkStatusCodeAndReturnResponse(url, entity, Method.POST, restTemplate, retryCount, retryInterval); }

Target:
public ResponseEntity<?> handleWithUserPasswordAndReturnType(MotechEvent motechEvent) { Map<String, Object> parameters = motechEvent.getParameters(); final String url = String.valueOf(parameters.get(SendRequestConstants.URL)); Object requestData = parameters.get(SendRequestConstants.BODY_PARAMETERS); String username = String.valueOf(parameters.get(SendRequestConstants.USERNAME)); String password = String.valueOf(parameters.get(SendRequestConstants.PASSWORD)); boolean followRedirects = (boolean) parameters.get(SendRequestConstants.FOLLOW_REDIRECTS); LOGGER.info(String.format("Posting Http request -- Url: %s, Data: %s", url, String.valueOf(requestData))); HttpEntity<Object> entity = new HttpEntity<>(requestData); RestTemplate restTemplate; if (StringUtils.isNotBlank(username) || StringUtils.isNotBlank(password)) { restTemplate = new RestTemplate(usernamePasswordRequestFactory( username, password)); } else { restTemplate = basicRestTemplate; } if (followRedirects) { final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); HttpClient httpClient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build(); factory.setHttpClient(httpClient); restTemplate.setRequestFactory(factory); } int retryCount = 1; long retryInterval = 0; if (parameters.get(EventDataKeys.RETRY_COUNT) != null) { retryCount = (int) parameters.get(EventDataKeys.RETRY_COUNT); } if (parameters.get(EventDataKeys.RETRY_INTERVAL) != null) { retryInterval = (long) parameters.get(EventDataKeys.RETRY_INTERVAL); } return sendRequest(url, entity, Method.POST, restTemplate, retryCount, retryInterval); }