I'm trying to update to the latest version (1.4.9) of com.loopj.android:android-async-http where org.apache.http was replaced with cz.msebera.android.httpclient.
At the moment I use:
StringEntity entity = new StringEntity("some data");
client.post(static_context, getAbsoluteUrl(url), entity, "application/json", responseHandler);
So I thought I can just cast it to HttpEntity which is not the case.
Caused by: java.lang.ClassCastException: org.apache.http.entity.StringEntity cannot be cast to cz.msebera.android.httpclient.HttpEntity
So my question is how can I create a HttpEntity with my data or is there a better way to create a post request with data in the body?
It looks like you import the wrong StringEntity class.
Assuming the cz.msebera.android.httpclient still has a StringEntity, you should be able to
import cz.msebera.android.httpclient.entity.StringEntity
instead of
import org.apache.http.entity.StringEntity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With