public InputStream sendRequest ( String requestMethod , Map < String , String > parameters ) throws IOException { String queryString = getQueryString ( parameters ) ; URL url = new URL ( this . apiBaseUrl ) ; HttpURLConnection connection = ( HttpURLConnection ) WebResourceFetcherImpl . getUrlConnection ( url ) ; setupConnection ( requestMethod , queryString , connection ) ; OutputStreamWriter writer = new OutputStreamWriter ( connection . getOutputStream ( ) ) ; writer . write ( queryString ) ; writer . flush ( ) ; writer . close ( ) ; int rc = connection . getResponseCode ( ) ; if ( rc != 200 ) { logger . warn ( "Error: API request returned response code " + rc ) ; } InputStream iStream = connection . getInputStream ( ) ; fillCookies ( connection . getHeaderFields ( ) ) ; return iStream ; }
Sends a request to the API with the given parameters and the given request method and returns the result string . It automatically fills the cookie map with cookies in the result header after the request .