public static void main()

in documentation-samples/endpoint-api-samples/java/call-endpoint.java [19:66]


    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {

            // The ID of a public sample LUIS app that recognizes intents for turning on and off lights
            String AppId = "df67dcdb-c37d-46af-88e1-8b97951ca1c2";
            
            // Add your endpoint key 
            // You can use the authoring key instead of the endpoint key. 
            // The authoring key allows 1000 endpoint queries a month.
            String EndpointKey = "YOUR-KEY";

            // Begin endpoint URL string building
            URIBuilder endpointURLbuilder = new URIBuilder("https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" + AppId + "?");

            // query text
            endpointURL.setParameter("q", "turn on the left light");

            // create URL from string
            URI endpointURL = endpointURL.build();

            // create HTTP object from URL
            HttpGet request = new HttpGet(endpointURL);

            // set key to access LUIS endpoint
            request.setHeader("Ocp-Apim-Subscription-Key", EndpointKey);

            // access LUIS endpoint - analyze text
            HttpResponse response = httpclient.execute(request);

            // get response
            HttpEntity entity = response.getEntity();


            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }

        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }