 <pre><code>Use this class package com.diluo.http; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HTTP; import android.app.ProgressDialog; import android.content.Entity; import android.os.AsyncTask; public class PostCall extends AsyncTask&lt;Void, Void, String&gt;{ private String url; private String request; private AsyncTaskListener callListener; private int pageId; private ProgressDialog dialog; public PostCall(String url,String request,ProgressDialog dialog,AsyncTaskListener callListener,int pageId) { this.url=url; this.request=request; this.callListener=callListener; this.pageId = pageId; this.dialog=dialog; } @Override protected String doInBackground(Void... params) { // TODO Auto-generated method stub try { System.out.println(request); System.out.println(url); HttpPost post = new HttpPost(this.url); StringEntity entity = new StringEntity(request,"UTF-8"); entity.setContentType("application/json"); entity.setContentEncoding(new BasicHeader("Content-type","application/json;charset=UTF-8")); post.setEntity(entity); post.addHeader("Content-type", "application/json;charset=UTF-80"); post.setHeader("Accept", "application/json"); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(post); // Collect the response HttpEntity entity1=response.getEntity(); if(entity1 != null&amp;&amp;(response.getStatusLine().getStatusCode()==201||response.getStatusLine().getStatusCode()==200)) { //--just so that you can view the response, this is optional-- int sc = response.getStatusLine().getStatusCode(); String sl = response.getStatusLine().getReasonPhrase(); String response_string=convertToString(entity1.getContent()); return response_string; } else { int sc = response.getStatusLine().getStatusCode(); String sl = response.getStatusLine().getReasonPhrase(); return null; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } private String convertToString(InputStream content) throws Exception{ InputStreamReader inputStreamReader=new InputStreamReader(content); BufferedReader bufferedReader=new BufferedReader(inputStreamReader); String s=""; StringBuffer buffer=new StringBuffer(); while ((s=bufferedReader.readLine())!=null) { buffer.append(s); } return buffer.toString(); } @Override protected void onPostExecute(String result) { if( callListener!= null){ super.onPostExecute(result); if(result != null){ try { System.out.println(result); callListener.onHttpResponse(result, pageId); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else{ callListener.onError("Please try again.", pageId); } if(this.dialog!=null){ dialog.dismiss(); } } cancel(true); } } </code></pre>