public <T> T invokeAPI(
       String path,
       String method,
       List<Pair> queryParams,
       List<Pair> collectionQueryParams,
       String urlQueryDeepObject,
       Object body,
       Map<String, String> headerParams,
       Map<String, String> cookieParams,
       Map<String, Object> formParams,
       String accept,
       String contentType,
       String[] authNames,
       TypeReference<T> returnType) throws ApiException {
    if (body != null && !formParams.isEmpty()) {
      throw new ApiException("Cannot have body and form params");
    }

    updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
    final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);

    RequestBuilder builder = RequestBuilder.create(method);
    builder.setUri(url);

    RequestConfig config = RequestConfig.custom()
      .setConnectionRequestTimeout(connectionTimeout)
      .build();
    builder.setConfig(config);

    if (accept != null) {
      builder.addHeader("Accept", accept);
    }
    for (Entry<String, String> keyValue : headerParams.entrySet()) {
      builder.addHeader(keyValue.getKey(), keyValue.getValue());
    }
    for (Entry<String,String> keyValue : defaultHeaderMap.entrySet()) {
      if (!headerParams.containsKey(keyValue.getKey())) {
        builder.addHeader(keyValue.getKey(), keyValue.getValue());
      }
    }

    BasicCookieStore store = new BasicCookieStore();
    for (Entry<String, String> keyValue : cookieParams.entrySet()) {
      store.addCookie(buildCookie(keyValue.getKey(), keyValue.getValue(), builder.getUri()));
    }
    for (Entry<String,String> keyValue : defaultCookieMap.entrySet()) {
      if (!cookieParams.containsKey(keyValue.getKey())) {
        store.addCookie(buildCookie(keyValue.getKey(), keyValue.getValue(), builder.getUri()));
      }
    }

    HttpClientContext context = HttpClientContext.create();
    context.setCookieStore(store);

    ContentType contentTypeObj = getContentType(contentType);
    if (body != null || !formParams.isEmpty()) {
      if (isBodyAllowed(method)) {
        // Add entity if we have content and a valid method
        builder.setEntity(serialize(body, formParams, contentTypeObj));
      } else {
        throw new ApiException("method " + method + " does not support a request body");
      }
    } else {
      // for empty body
      builder.setEntity(new StringEntity("", contentTypeObj));
    }

    try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
      return processResponse(response, returnType);
    } catch (IOException e) {
      throw new ApiException(e);
    }
  }
Invoke API by sending HTTP request with the given options.

@param <T> Type
@param path The sub-path of the HTTP URL
@param method The request method, one of "GET", "POST", "PUT", and "DELETE"
@param queryParams The query parameters
@param collectionQueryParams The collection query parameters
@param urlQueryDeepObject A URL query string for deep object parameters
@param body The request body object - if it is not binary, otherwise null
@param headerParams The header parameters
@param cookieParams The cookie parameters
@param formParams The form parameters
@param accept The request's Accept header
@param contentType The request's Content-Type header
@param authNames The authentications to apply
@param returnType Return type
@return The response body in type of string
@throws ApiException API exception
plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/rest/datalayer/ApiClient.java