0
After researching a lot I found my solution and here.
Path path path = Paths.get("/Users/Alexandre/notanvio.xml");
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(URL);
FileBody fileBody = new FileBody(path.toFile(), ContentType.DEFAULT_BINARY);
StringBody stringBody1 = new StringBody("15425039000128", ContentType.MULTIPART_FORM_DATA);
StringBody stringBody2 = new StringBody("154250", ContentType.MULTIPART_FORM_DATA);
StringBody stringBody3 = new StringBody("7513", ContentType.MULTIPART_FORM_DATA);
//
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("login", stringBody1);
builder.addPart("senha", stringBody2);
builder.addPart("cidade", stringBody3);
builder.addPart("f1", fileBody);
HttpEntity entity = builder.build();
//
post.setEntity(entity);
HttpResponse response = client.execute(post);
Hi Luiz, so it didn’t work, this Namevaluepair class doesn’t have in the library I downloaded, and the Basicnamevaluepair class I found does not accept File as second parameter.
– Alexandre Robaert