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 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", ""));
  4. httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Parsed in 0.017 seconds, using GeSHi

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' => '',
  3. ));
Parsed in 0.020 seconds, using GeSHi

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


Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 3 guests