0

I want to make an HTTP request with Java, but I'm new to Java and have no clue how. I've had a look at a few tutorials, but I was unable to understand anything. I want to send JSON data and also receive JSON data. In Python it would look like this:

response = json.load(urllib.request.urlopen(urllib.request.Request('http://localhost:8765', requestJson)))

Any help would be much appreciated.

DwB
  • 37,124
  • 11
  • 56
  • 82

1 Answers1

0

Use the below link for reference https://www.baeldung.com/java-http-request

You can use rest template also if you're using external library.

ResponseEntity<> response = restTemplate.exchange(
                    UriComponentsBuilder.fromHttpUrl(baseurl + "jobs").toString(),
                    HttpMethod.POST,
                    new HttpEntity<>(body,headers),
                    <someClass>.class);