code: private static HttpEntityEnclosingRequestBase completeRequest(
        final HttpEntityEnclosingRequestBase request,
        final List<Pair<String, String>> params) throws UnsupportedEncodingException {
      if (request != null) {
        if (null != params && !params.isEmpty()) {
          final List<NameValuePair> formParams = params.stream()
              .map(pair -> new BasicNameValuePair(pair.getFirst(), pair.getSecond()))
              .collect(Collectors.toList());
          final HttpEntity entity = new UrlEncodedFormEntity(formParams, "UTF-8");
          request.setEntity(entity);
        }
      }
      return request;
    }
docs: helper function to fill  the request with header entries and posting body .