org.apache.http.client.HttpResponseException:错误的请求

时间:2018-04-21 06:30:16

标签: android json httpclient asynchttpclient loopj

我想通过LoopJ's AndroidAsyncHttp将JSON作为POST发送到我的localhost服务器。当我运行时它给出了这个错误

  

400 - org.apache.http.client.HttpResponseException:错误请求

我发送的JSON数据

{"username":"abraham","email":"abr@gmail.com","password":"123"}
  

代码

public void invokeWS(JSONObject json) throws UnsupportedEncodingException
{
        ByteArrayEntity entity = new ByteArrayEntity(json.toString().getBytes("UTF-8"));
        entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
        AsyncHttpClient client = new AsyncHttpClient();

        client.post(getApplicationContext(), "http://0.0.0.0:8080/WebService/rest/users/insert", entity, "application/json", new JsonHttpResponseHandler(){

我打印了entity并返回

org.apache.http.entity.ByteArrayEntity@2b701463

0 个答案:

没有答案