i am trying to create a user login page, i am getting this error while i try to register.I guess there is a problem with the Json object part.I tried searching for other answers in the forum but none of seem to address my problem. Request you to help me out with this. Thanks is advance.
public void registercheck(final String name, final String email, final String password) {
String tag_req = "Register_request";
pdialog.setMessage("Registering ...");
showDialog();
StringRequest strR = new StringRequest(Request.Method.POST, Appconfig.LOGIN_URL, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
hidedialog();
try {
JSONObject jsp = new JSONObject(s);
boolean error = jsp.getBoolean("error");
if (!error) {
String uid = jsp.getString("uid");
JSONObject user = jsp.getJSONObject("user");
String name = user.getString("name");
String email = user.getString("email");
String created_at = user.getString("created_at");
db.addUser(name, email, uid, created_at);
session.setLogin(true);
Intent i = new Intent(Register.this, MainActivity.class);
startActivity(i);
finish();
} else {
String error_msg = jsp.getString("error_msg");
Toast.makeText(Register.this, error_msg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.e(TAG, volleyError.getMessage());
}
}) {
@Override
public Map<String, String> getParams() {
Map<String, String> p = new HashMap<String, String>();
p.put("name", name);
p.put("tag", "register");
p.put("email", email);
p.put("password", password);
return p;
My Log cat
15.407 11021-11440/example.com.login E/Volley﹕ [2407] BasicNetwork.performRequest: Unexpected response code 500 for http://busappandroid.gear.host/
myReq.setRetryPolicy(new DefaultRetryPolicy(10000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
Add this line before addidng your request in volley.
This is the minimum number of retries. Default is 1.
add header Content-Type - text/html. I tried to call your api from postman rest client without headers it will give error 500 after adding header to api got result 200 status ok