0

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.

  • remove the `cz.msebera.android:htttpclient:4.3.6` libray and follow this question https://stackoverflow.com/questions/32340629/cant-import-org-apache-http-httpresponse-in-android-studio to implemenmt apache httpclient. The use HtttpEntity insted of ByteArrayEntity – Tomin B Azhakathu Apr 21 '18 at 04:53
  • @TominB I will do it and let you know. Thanks for the answer. –  Apr 21 '18 at 04:56

0 Answers0