dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Feb 24, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


How to Trigger a Synchronous GET Request

For triggering a synchronous GET request we can rely on HTTP Client API as follows:

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()               
    .uri(URI.create("https://reqres.in/api/users/2"))                
    .build();

HttpResponse response = client.send(request, BodyHandlers.ofString());
Octavia Anghel
 
Thanks for your registration, follow us on our social networks to keep up-to-date