code: private HttpUriRequest prepareRequest(HttpMethod method, String apiUrl, Map<String, ?> params, Map options) throws URISyntaxException, UnsupportedEncodingException {
          URI apiUri;
          HttpRequestBase request;
  
          String contentType = ObjectUtils.asString(options.get("content_type"), "urlencoded");
          URIBuilder apiUrlBuilder = new URIBuilder(apiUrl);
          HashMap<String,Object>  unboxedParams = new  HashMap<String,Object>(params);
  
          if (method == HttpMethod.GET) {
              apiUrlBuilder.setParameters(prepareParams(params));
              apiUri = apiUrlBuilder.build();
              request = new HttpGet(apiUri);
          } else {
              apiUri = apiUrlBuilder.build();
              switch (method) {
                  case PUT:
                      request = new HttpPut(apiUri);
                      break;
                  case DELETE: //uses HttpPost instead of HttpDelete
                      unboxedParams.put("_method","delete");
                      //continue with POST
                  case POST:
                      request = new HttpPost(apiUri);
                      break;
                  default:
                      throw new IllegalArgumentException("Unknown HTTP method");
              }
              if (contentType.equals("json")) {
                  JSONObject asJSON = ObjectUtils.toJSON(unboxedParams);
                  StringEntity requestEntity = new StringEntity(asJSON.toString(), ContentType.APPLICATION_JSON);
                  ((HttpEntityEnclosingRequestBase) request).setEntity(requestEntity);
              } else {
                  ((HttpEntityEnclosingRequestBase) request).setEntity(new UrlEncodedFormEntity(prepareParams(unboxedParams), Consts.UTF_8));
              }
          }
  
          setTimeouts(request, options);
          return request;
      }
docs: Prepare a request with the URL and parameters based on the HTTP method used
  
  @param method the HTTP method: GET, PUT, POST, DELETE
  @param apiUrl the cloudinary API URI
  @param params the parameters to pass to the server
  @return an HTTP request
  @throws URISyntaxException
  @throws UnsupportedEncodingException