How to send POST method in Android, one parameters needs to be String and another JSON object ?
String parameter is "age"
JSONObject createRequest = new JSONObject();
try {
createRequest.put("ID", 2173);
createRequest.put("Name", "Munja");
createRequest.put("Address", "New York");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
//nameValuePairs.add(new BasicNameValuePair("client", createRequest.toString()));
nameValuePairs.add(new BasicNameValuePair("age", "21"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
StringEntity se = new StringEntity( createRequest.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost.setEntity(se);
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
but it doesn't work, receives 400, like it is not formed well.