I try to upload files with webClient Spring5 (multipart/form-data), but I got 400 Badrequest there is my code (when i try with restTemplate all work fine), don't understand why not work with webclient, any help is precious, thanks in advance...
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("subject", parametres.getSubject());
builder.part("lifetime", parametres.getLifeTime());
builder.part("comment", parametres.getComment());
builder.part("encrypted", parametres.getEncrypted());
builder.part("file", new FileSystemResource(file)).filename(file.getName()) //file is a java.io.File`
ClientResponse response = getClient().post()
.uri("/messages")
.body(BodyInserters.fromMultipartData(builder.build()))
.header(PlinePlexHeaderEnum.HTTP_HEADER_PROCURATION_USER_ID.value(), idUser))
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
.exchange().block();
Try this: