Android - cz.msebera.android.httpclient.entity.Byt

2019-08-28 02:05发布

I am using loopj AsyncHttpClient to call web services. I am trying register a user. So I need to send JSON data to Web Service.

ByteArrayEntity entity = new ByteArrayEntity(json.toString().getBytes("UTF-8"));
entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

client.post(getApplicationContext(), "http://10.0.3.2:8080/WebService/rest/user/insert", entity, new JsonHttpResponseHandler(){

When I put cursor on the entity in client.post line it gives this error.

cz.msebera.android.httpclient.entity.ByteArrayEntity required: org.apache.http.HttpEntity

Example That I am trying is also from stack-overflow - Send JSON as a POST request to server by AsyncHttpClient

Libraries that I am using

compile files('libs/android-async-http-1.4.4.jar')
compile 'cz.msebera.android:httpclient:4.3.6'

Anybody can help me? Thanks in advance.

0条回答
登录 后发表回答