How to set http header to sending json object from our android apps what type of header we want to use for sending data from client side to server.why we ar
try this:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://floating-wildwood-1154.herokuapp.com/posts/create_a_post");
// Add Headers
httppost.addHeader("key1", "value1");
httppost.addHeader("key2", "value2");
try {
// Add your data
List nameValuePairs = new ArrayList();
nameValuePairs.add(new BasicNameValuePair("content", valueIWantToSend));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}