Witam wszystkich. Mam pewien problem. Mam taki o to kod:
public void checkLogin(String email) {
//Set default HTTP Client
HttpClient httpClient = new DefaultHttpClient();
//Set user email
user.setEmail(email);
//Convert user email into JSON format
String userEmail = ToJson.emailToJson(user);
//Declare connection to the server to see if the email is already in the database
HttpGet httpGet = new HttpGet("http://1.1.1.1:27080/users/login/_find?criteria=" + userEmail);
//Try to get the HTTP Response
try {
//Create HTTP Response and pass it to the HTTP Client
HttpResponse response = httpClient.execute(httpGet);
String responseStr = EntityUtils.toString(response.getEntity());
//Write Response to LOG
Log.d("HTTP Post Response:", responseStr);
} catch(ClientProtocolException e) {
//Log the exception
e.printStackTrace();
} catch(IOException e) {
//Log the exception
e.printStackTrace();
}
}
Jest to wstępna metoda do sprawdzania danych w bazie danych MongoDB. Po przekazaniu obiektu JSON do zmiennej String, następnie przekazaniu tej zmiennej do URL, wywala mi błąd:
09-25 15:15:52.912: E/AndroidRuntime(12904): java.lang.IllegalArgumentException: Illegal character in query at index 56: http://1.1.1.1:27080/users/login/_find?criteria={"email":"dffff"}
Nie wiem za bardzo jak sobie z tym poradzić, próbowałem użyc biblioteki StringEscapeUtils z metoda escapeJava ale nic to nie dało...
Macie jakieś pomysły?