I am trying to send a MultipartEntityBuilder
to my Rails server. However when i try to build it it crashes and gives me the error
03-25 09:44:50.001 W/System.err﹕ java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: No static method create(Ljava/lang/String;[Lorg/apache/http/NameValuePair;)Lorg/apache/http/entity/ContentType; in class Lorg/apache/http/entity/ContentType; or its super classes (declaration of 'org.apache.http.entity.ContentType
HttpPost httpost = new HttpPost(url);
MultipartEntityBuilder entity = new MultipartEntityBuilder.create();
entity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
for(int index=0; index < nameValuePairs.size(); index++) {
ContentBody cb;
if(nameValuePairs.get(index).getName().equalsIgnoreCase("File")) {
File file = new File(nameValuePairs.get(index).getValue());
FileBody isb = new FileBody(file);
entity.addPart(nameValuePairs.get(index).getName(), isb);
} else {
// Normal string data
cb = new StringBody(nameValuePairs.get(index).getValue(),ContentType.TEXT_PLAIN);
entity.addPart(nameValuePairs.get(index).getName(),cb);
}
}
return entity.build();
This is the code i am using and i am still getting errors on the building of the the MultipartEntity it'll say the error.
Try using httpmime version 4.3.6
I tried using 4.4+ but always the same problem.
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