0

I want to make an http query using the java http client (HttpClient). The server I am querying is a service on Docker to which I can access with its service name.

Here is my code :


            URIBuilder uriBuilder = new URIBuilder()
                .setScheme("http")
                .setHost("my_docker_service_name:5000" + "/balance/")
                .setParameter("account_id", "1")
                .setParameter("timestamp", "1596637676")
            ;


            HttpRequest httpRequest = HttpRequest.newBuilder()
                .GET()
                .uri(uriBuilder.build())
                .build();

With this I get the following error :

java.lang.IllegalArgumentException: unsupported URI http://my_docker_service_name:5000/?account_id=1&timestamp=1596637676

If I replace my_docker_service_name by an ipv4 address, the http request works as expected.

Do you see what I might be doing wrong ?

Many thanks for your help

Enigma2684
  • 75
  • 4

1 Answers1

0

I found the problem with my request : the uri contains underscores which are not supported on the http java client as stated on this answer https://stackoverflow.com/a/28568413/6744511

Enigma2684
  • 75
  • 4