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

旧巷老猫 提交于 2020-01-06 08:12:45

问题


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.

来源:https://stackoverflow.com/questions/49949643/android-cz-msebera-android-httpclient-entity-bytearrayentity-required-org-apa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!