From the course: Calling REST APIs with Java
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Java HTTP Client - Java Tutorial
From the course: Calling REST APIs with Java
Java HTTP Client
- Java 11 introduced a new HTTP client that makes it much easier to call an API with Java. Here's an example of an API request to Azure Cognitive Services that was written prior to Java 11. You can see there's quite a bit of code and it required us to do things like handle the IO for a request or a response body. This often led to errors where we would forget to close our resources. Luckily the HTTP client makes it much simpler in Java 11. It also supports HTTP/2, so you can benefit from the performance enhancements delivered by that new version of the protocol. To see how it works, let's build a call to another API within Azure Cognitive Services. Within the Azure entities test class, we'll create a unit test that calls the named entities recognition endpoint on the text analytics API. This endpoint can extract people, places, and organizations from the texts that we provide. To help us out, I've added a number of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Azure Cognitive Services5m 40s
-
(Locked)
Text Analytics API registration and security7m 34s
-
(Locked)
Java HTTP Client9m 29s
-
(Locked)
Calling Azure Cognitive Services APIs7m 9s
-
(Locked)
Asynchronous API calls6m 50s
-
(Locked)
Challenge: Cognitive Services API3m 25s
-
(Locked)
Solution: Cognitive Services API4m 54s
-
-
-
-