androidandroidhttpclient

Android org.apache.http.client.HttpResponseException: Not Found


In my app I send user information to server with http as follows, I get org.apache.http.client.HttpResponseException: Not Found and I have spend more time but could not solution.please help me find out the solution.

I get error at this line:

jsonResponse = httpClient.execute(httpPost, resHandler);

public String addNewCardDetail(String loggedin_id, String fn, String ln,
        String cardholdername, String cardno,String cvv, String expdate, String add,
        String state, String city, String pincode) {

    jsonResponse = "";

    httpClient = new DefaultHttpClient();
    resHandler = new BasicResponseHandler();
    httpPost = new HttpPost("http://xxx.xxx.xxx.xx/users/createCustomerCardAddress");
    nameValuePairs = new ArrayList<NameValuePair>(11);

    nameValuePairs.add(new BasicNameValuePair("loggedin_id",loggedin_id));
    nameValuePairs.add(new BasicNameValuePair("firstname",fn));
    nameValuePairs.add(new BasicNameValuePair("lastname",ln));
    nameValuePairs.add(new BasicNameValuePair("cardHolderName",cardholdername));
    nameValuePairs.add(new BasicNameValuePair("cardNumber",cardno));
    nameValuePairs.add(new BasicNameValuePair("cardCvv",cvv));
    nameValuePairs.add(new BasicNameValuePair("expDate",expdate));
    nameValuePairs.add(new BasicNameValuePair("address",add));
    nameValuePairs.add(new BasicNameValuePair("state",state));
    nameValuePairs.add(new BasicNameValuePair("city",city));
    nameValuePairs.add(new BasicNameValuePair("pincode",pincode));

    Log.e("----------", "---------");
    for (int i = 0; i < nameValuePairs.size(); i++) {
        Log.e("add / edit new card", nameValuePairs.get(i).getName());
        Log.e("add / edit new card", nameValuePairs.get(i).getValue());
    }
    Log.e("----------", "---------");

    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        jsonResponse = httpClient.execute(httpPost, resHandler); // I get org.apache.http.client.HttpResponseException: Not Found 
        Log.e("add edit card response", "-"+jsonResponse);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return jsonResponse;
}

My Log trace:

org.apache.http.client.HttpResponseException: Not Found
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:773)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:743)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.fssd.spot.parser.ParsorClass.addNewCardDetail(ParsorClass.java:1098)
at com.fssd.spot.payment.BillingAddress$AddNewcard.doInBackground(BillingAddress.java:146)
at com.fssd.spot.payment.BillingAddress$AddNewcard.doInBackground(BillingAddress.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

Solution

  • The Api given is invalid so that I get this exception. now I get valid api and working. Thanks.