public static HttpResponse invokeHttpRequest(URL endpointUrl,String httpMethod,Map<String,String> headers,String requestBody){
  HttpURLConnection connection=createHttpConnection(endpointUrl,httpMethod,headers);
  try {
    if (requestBody != null) {
      DataOutputStream wr=new DataOutputStream(connection.getOutputStream());
      wr.writeBytes(requestBody);
      wr.flush();
      wr.close();
    }
  }
 catch (  Exception e) {
    throw new RuntimeException("Request failed. " + e.getMessage(),e);
  }
  return executeHttpRequest(connection);
}

public static HttpResponse invokeHttpRequest ( URL endpointUrl , String httpMethod , Map < String , String > headers , String requestBody ) { HttpURLConnection connection = createHttpConnection ( endpointUrl , httpMethod , headers ) ; try { if ( requestBody != null ) { DataOutputStream wr = new DataOutputStream ( connection . getOutputStream ( ) ) ; wr . writeBytes ( requestBody ) ; wr . flush ( ) ; wr . close ( ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Request failed. " + e . getMessage ( ) , e ) ; } return executeHttpRequest ( connection ) ; }
makes a http request to the specified endpoint
