private String makeParamsString(Map<String, String> params, boolean isGet) {
		StringBuilder url = new StringBuilder();
		if (params != null) {
			boolean first = true;
			for (Map.Entry<String, String> entry : params.entrySet()) {
				if (first) {
					if (isGet) {
						url.append("?");
					}
					first = false;
				} else {
					url.append("&");
				}
				try {
					// Hay que codificar los valores de los parametros para que
					// las llamadas REST se hagan correctamente
				    if (entry.getValue() != null) {
				        url.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), CHARSET));
				    } else {
		                LOGGER.debug("WARN - Param {} is null", entry.getKey());
                        url.append(entry.getKey()).append("=").append("");
				    }
				} catch (UnsupportedEncodingException ex) {
					// Esta excepcion saltaria si la codificacion no estuviese
					// soportada, pero UTF-8 siempre esta soportada.
					LOGGER.error(ex.getLocalizedMessage());
				}
			}
		}
		return url.toString();
	}
private String makeParamsString ( Map < String , String > params , boolean isGet ) { StringBuilder url = new StringBuilder ( ) ; if ( params != null ) { boolean first = true ; for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { if ( first ) { if ( isGet ) { url . append ( "?" ) ; } first = false ; } else { url . append ( "&" ) ; } try { if ( entry . getValue ( ) != null ) { url . append ( entry . getKey ( ) ) . append ( "=" ) . append ( URLEncoder . encode ( entry . getValue ( ) , CHARSET ) ) ; } else { LOGGER . debug ( "WARN - Param {} is null" , entry . getKey ( ) ) ; url . append ( entry . getKey ( ) ) . append ( "=" ) . append ( "" ) ; } } catch ( UnsupportedEncodingException ex ) { LOGGER . error ( ex . getLocalizedMessage ( ) ) ; } } } return url . toString ( ) ; }
Adds params to a query string. It will encode params' values to not get
errors in the connection.

@param params
Parameters and their values.
@param isGet
Indicates a GET request. A GET request has to mark the first
parameter with the '?' symbol. In a POST request it doesn't
have to do it.
@return a string with the parameters. This string can be appended to a
query string, or written to an OutputStream.