I am trying to send a call to a remote server with user credentials, and get back a true/false for whether the persons credentials match. But my code is returning the credentials right back to me in JSON lol
try
{
String query = String.format("login=%s&password=%s",
URLEncoder.encode(myEmail, charset),
URLEncoder.encode(myPassword, charset));
final URL url = new URL( myUrl + "?" + query );
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("login", myEmail);
conn.setRequestProperty("password", myPassword);
conn.setUseCaches(false);
final InputStream is = conn.getInputStream();
final byte[] buffer = new byte[8196];
int readCount;
final StringBuilder builder = new StringBuilder();
while ((readCount = is.read(buffer)) > -1)
{
builder.append(new String(buffer, 0, readCount));
}
response = builder.toString();
Log.d( "After call, response: " , " " + response);
}
catch (Exception e)
{
Log.d( "Exception: " , "Yup");
e.printStackTrace();
}
Would anyone know how I can get the output from the server instead of this stuff that I get back now?
Thanks!
Surprisingly the code you have posted works on my standalone java client as well as in my android app. It seems something is wrong on the server part. Can you post any additional output from server??
On server I have a servlet which receives user and passcode in JSON format and returns validation result in json format back.