Sending an Post Request of an Array using Volley android -
i relatively new android , trying send array rails server in form
"user"=>{"name"=>"jackson", "email"=>"jack@yahoo.com", "password"=>"[filtered]", "password_confirmation"=>"[filtered]"}
i don't know if doing correctly here have. have user class save data
public class user { private string name; private string email; private string password; private string password_confirmation; public user(string name, string email, string password, string password_confirmation) { this.name = name; this.email = email; this.password = password; this.password_confirmation = password_confirmation; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getemail() { return email; } public void setemail(string email) { this.email = email; } public string getpassword() { return password; } public void setpassword(string password) { this.password = password; } public string getpasswordconfirmation() { return password_confirmation; } public void setpasswordconfirmation(string password_confirmation) { this.password_confirmation = password_confirmation; } }
i input using
inputusername = (edittext) findviewbyid(r.id.fld_username); inputemail = (edittext) findviewbyid(r.id.fld_email); inputpassword = (edittext) findviewbyid(r.id.fld_pwd); inputpasswordconfirmation = (edittext) findviewbyid(r.id.fld_pwd_confirm); btnlogin = (button) findviewbyid(r.id.btn_login); final requestqueue queue = volley.newrequestqueue(this); btnlogin.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { final user user = new user(null, null, null, null); user.setname(string.valueof(inputusername.gettext())); user.setemail(string.valueof(inputemail.gettext())); user.setpassword(string.valueof(inputpassword.gettext())); user.setpasswordconfirmation(string.valueof(inputpasswordconfirmation.gettext()));
now stuck making post request. have tried sending email using
protected map<string,string> getparams(){ map<string, string> params = new hashmap<string, string>(); params.put("email",email); return params; }
but sends data {"email"=>"example@gmail.com"}
instead of "user"= {"name"=>"example@gmail.com"}
can please show me going wrong, thanks.
try maybe:
protected map<string,string> getparams(){ map<string, string> params = new hashmap<string, string>(); map<string, string> user = new hashmap<string, string>(); user.put("email",email); params.put("user", user); return params; }
Comments
Post a Comment