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.

Solution: Cognitive Services API

Solution: Cognitive Services API - Java Tutorial

From the course: Calling REST APIs with Java

Start my 1-month free trial

Solution: Cognitive Services API

(upbeat music) - [Instructor] How did it go? Were you able to find a working solution? Let's take a look at how I chose to solve the problem. Now don't worry if your code doesn't match mine exactly, it's more about getting experience calling an API and working with Azure Cognitive Services. I've also added some bells and whistles in my example so that you can see more of the HTTP client interface. Okay, so I started off by building a TextDocument object and a TextAnalyticsRequest object. These are going to store the information that we're going to pass in the request body of the HTTP request, to the text analytics API. Now after I built those objects, I created the URI to the Azure Cognitive Services Sentiment endpoint. To do that, I concatenated the path to Version 3 of the endpoint, with the domain specific to my resource in Azure Cognitive Services. You can see that as a constant in the top of the class. Remember…

Contents