I have done raw rest get and post and also could do post in namevaluepair but no matter which tutorial i follow i just cant get json post done ...
Android Application:
ArrayList<String> stringData = new ArrayList<String>();
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postMethod = new HttpPost("http://192.168.1.10/people.php");
JSONObject holder = new JSONObject();
holder.put("name", "Foo");
holder.put("occupation", "Bar");
StringEntity se = new StringEntity(holder.toString());
postMethod.setEntity(se);
postMethod.setHeader("Accept", "application/json");
postMethod.setHeader("Content-type", "application/json");
ResponseHandler <String> resonseHandler = new BasicResponseHandler();
String response=httpClient.execute(postMethod,resonseHandler);
stringData.add(response);
return stringData;
PHP file:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
var_dump($_POST);
}
the var_dump just gives an empty array and $_POST["name"] gives undefined index ... any help would be nice