public static String get ( String url , Map < String , String > customHeaders , Map < String , String > params ) throws URISyntaxException , IOException , HTTPException { LOGGER . log ( Level . INFO , "Sending GET request to the url {0}" , url ) ; URIBuilder uriBuilder = new URIBuilder ( url ) ; if ( params != null && params . size ( ) > 0 ) { for ( Map . Entry < String , String > param : params . entrySet ( ) ) { uriBuilder . setParameter ( param . getKey ( ) , param . getValue ( ) ) ; } } HttpGet httpGet = new HttpGet ( uriBuilder . build ( ) ) ; populateHeaders ( httpGet , customHeaders ) ; HttpClient httpClient = HttpClientBuilder . create ( ) . build ( ) ; HttpResponse httpResponse = httpClient . execute ( httpGet ) ; int statusCode = httpResponse . getStatusLine ( ) . getStatusCode ( ) ; if ( isErrorStatus ( statusCode ) ) { String jsonErrorResponse = EntityUtils . toString ( httpResponse . getEntity ( ) , StandardCharsets . UTF_8 ) ; throw new HTTPException ( statusCode , httpResponse . getStatusLine ( ) . getReasonPhrase ( ) , jsonErrorResponse ) ; } return EntityUtils . toString ( httpResponse . getEntity ( ) , StandardCharsets . UTF_8 ) ; }
Send get request .