Result (@NotNull String entryPoint, int idePort, @NotNull String handlerId, @Nullable String bodyContent) { try { // allow self-signed certificates of IDE TrustManager[] tm = {new AllowingTrustManager()}; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, tm, null); HttpClient client = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_2) .sslContext(sslContext) .connectTimeout(Duration.ofSeconds(5)) .build(); HttpRequest.Builder requestBuilder = HttpRequest.newBuilder() .uri(URI.create(String.format("https://127.0.0.1:%s/api/%s?%s=%s", idePort, entryPoint, ExternalAppHandler.HANDLER_ID_PARAMETER, handlerId))); if (bodyContent != null) { requestBuilder.POST(HttpRequest.BodyPublishers.ofString(bodyContent)); } else { requestBuilder.POST(HttpRequest.BodyPublishers.noBody()); } HttpResponse<String> response = client.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString()); int statusCode = response.statusCode(); if (statusCode == HttpURLConnection.HTTP_OK) { return Result.success(statusCode, response.body()); } else if (statusCode == HttpURLConnection.HTTP_NO_CONTENT) { return Result.success(statusCode, null); } else { return Result.error(statusCode, response.body()); } } catch (IOException | InterruptedException | NoSuchAlgorithmException | KeyManagementException e) { throw new RuntimeException(e); } }