private JSONObject sendGetRequest ( String url , Integer type , HashMap < String , String > params ) throws JSONException { String fullUrl = getFullUrl ( url ) ; HttpGet request = new HttpGet ( fullUrl ) ; if ( params != null ) { URI uri ; String query = "" ; try { URIBuilder uriBuilder = new URIBuilder ( request . getURI ( ) ) ; // encode values and add them to the request for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { String key = entry . getKey ( ) ; String value = entry . getValue ( ) ; // to prevent double encoding, we need to create query string ourself // uriBuilder.addParameter(key, URLEncoder.encode(value).replace("%3B", ";")); query = query + key + "=" + value . replace ( "&" , "&amp;" ) + "&" ; // what the hell is going on in java - no adequate way to encode query string // lets temporary replace "&" in the value, to encode it manually later } // this routine will encode query string uriBuilder . setCustomQuery ( query ) ; uri = uriBuilder . build ( ) ; // re-create request to have validly encoded ampersand request = new HttpGet ( fullUrl + "?" + uri . getRawQuery ( ) . replace ( "&amp;" , "%26" ) ) ; } catch ( URISyntaxException e ) { // TODO Auto-generated catch block e . printStackTrace ( ) ; } } try { mOAuthConsumer . sign ( request ) ; } catch ( OAuthException e ) { e . printStackTrace ( ) ; } return UpworkRestClient . getJSONObject ( request , type ) ; }
Send signed GET OAuth request