HttpPost 2d parameters.

Quickly share your Android Code Snippets here...

HttpPost 2d parameters.

Postby Khan Talha » Thu Jul 28, 2011 10:32 am

(server side verification)

Code: Select all
if request.post? and not params[:user].blank? and not params[:user][:email].blank? ...


(Client side)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
  2. nameValuePairs.add(new BasicNameValuePair("user", null));
  3. nameValuePairs.add(new BasicNameValuePair("email", "abc@gmail.com"));
  4. httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  5.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

but server is unable to parse my request and send me that "email is empty".

Basically what i need is to to product the Java equivalent of this PHP:
Syntax: [ Download ] [ Hide ]
Using php Syntax Highlighting
  1. $params = array('user' => array(
  2.     'email' => 'abc@gmail.com',
  3. ));
  4.  
Parsed in 0.057 seconds, using GeSHi 1.0.8.4


And this is the same request in JSON format:
Code: Select all
{"user":{"firstname":"Bob Smith","lastname":"Johnson"}}
Khan Talha
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Aug 30, 2010 6:25 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 2 guests