在android上发送带有身份验证的json对象时请求错误

在android上发送带有身份验证的json对象时请求错误,android,json,authentication,http-post,httpclient,Android,Json,Authentication,Http Post,Httpclient,当我尝试发送带有身份验证的json对象时,收到错误错误请求。我看了一下,但它并没有解决我的问题 public void getServerData() throws JSONException, ClientProtocolException, IOException { ArrayList<String> stringData = new ArrayList<String>(); DefaultHttpClient httpClient = new D

当我尝试发送带有身份验证的json对象时,收到错误
错误请求。我看了一下,但它并没有解决我的问题

public void getServerData() throws JSONException, ClientProtocolException, IOException {

    ArrayList<String> stringData = new ArrayList<String>();
    DefaultHttpClient httpClient = new DefaultHttpClient();
    ResponseHandler <String> resonseHandler = new BasicResponseHandler();

    byte[] data = "myusername:mypassword".getBytes("UTF-8");
    String encoding = Base64.encodeToString(data, Base64.DEFAULT);

    HttpPost postMethod = new HttpPost("http://url/email_check.json");
    postMethod.setHeader(HTTP.CONTENT_TYPE, "application/json");

    postMethod.setHeader("Authorization", "Basic " + encoding);

    JSONObject json = new JSONObject();
    json.put("email","somebody@email.com");


    postMethod.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
    String response = httpClient.execute(postMethod,resonseHandler);
    Log.e("response :", response);
    }

知道哪里出了问题吗?

您需要在问题中包含完整的错误(包括状态代码和消息)。此外,如果您有权访问服务器,请在日志中查找相应的异常,并将其包括在问题中。
cause: org.apache.http.client.HttpResponseException: Bad Request
detailMessage: Bad Request
stackState: (id=830103290336)
stackTrace: null
statusCode: 400