java - Android HTTPGet to Rails REST Login -


i have login needs email , password.

if hit postman rest client this:

www.site.com/login.json?session[email]=bob@gmail.com&session[password]=password 

the server (rails) read fine, this:

{"session"=>{"email"=>"bob@gmail.com", "password"=>"password"}, "action"=>"create", "controller"=>"sessions", "format"=>"json"} 

but, if send in same thing httpget android, this:

            httpclient httpclient = new defaulthttpclient();              //get parameters             string email = params[0];             string password = params[1];              string url = "http://www.site.com/login.json?session[email]=" + email + "?session[password]=" + password;              httpget httpget = new httpget(url);              httpget.setheader("accept", "application/json");             httpget.setheader("content-type", "application/json"); response = httpclient.execute(httpget); 

the server doesn't recognize parameters, , end empty json object this:

{"session"=>{}, "action"=>"create", "controller"=>"sessions", "format"=>"json"} 

anybody know how form parameters in httpget call in android work in rest client call? thanks!

it seems have typo in url , params messed up. line:

string url = "http://www.site.com/login.json?session[email]=" + email + "?session[password]=" + password; 

should be

string url = "http://www.site.com/login.json?session[email]=" + email + "&session[password]=" + password; 

note i've replaced ?session[password]= &session[password]=.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -