Error 405 when using HttpPost on Android [closed]

3

When you do a post on the server through Android HttpPost , I get a 405 error. only when part of Android I get this error. Does anyone know why?

My code on Android is:

private class sendSignUpPost extends AsyncTask<String, Void, String> {

ProgressDialog dialog = new ProgressDialog(SignUp.this);

@Override
protected void onPreExecute() {
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setCancelable(false);
    dialog.setMax(100);
    dialog.setMessage(getString(R.string.text_check_data));
    dialog.show();
    checkConnection();
    //checkFields();
}

@Override
protected String doInBackground(String... params) {

    dialog.setMessage(getString(R.string.text_creating_account));
    dialog.setProgress(75);

    JSONObject jsonObjSend = new JSONObject();
    try {
        jsonObjSend.put("action", "signup");
        jsonObjSend.put("firstname", FIRSTNAME);
        jsonObjSend.put("lastname", LASTNAME);
        jsonObjSend.put("email", EMAIL);
        jsonObjSend.put("password", PASSWORD);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://nerd.com.br/");
    httppost.setHeader("User-Agent", "br.com.nerd");
    httppost.setHeader("Accept", "application/json");
    httppost.setHeader("Content-Type", "application/json");
    StringEntity se = null;
    try {
        se = new StringEntity(jsonObjSend.toString());
        se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    httppost.setEntity(se);
    HttpResponse response = null;

    try {
        response = httpclient.execute(httppost);
        System.out.println("=============>" + httppost);
    } catch (ClientProtocolException e) {
        Toast.makeText(getApplicationContext(), R.string.text_check_network, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }



    BasicResponseHandler responseHandler = new BasicResponseHandler();
    String strResponse = null;
    if (response != null) {
        try {
            strResponse = responseHandler.handleResponse(response);
            System.out.println("=============>" + response);
        } catch (HttpResponseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return strResponse;
}
    
asked by anonymous 05.09.2014 / 20:44

1 answer

0

I'll put the answer here so others can see that the question was answered:

"The problem was related to the domain that had not been propagated ."

    
18.09.2014 / 16:36