How do I post the following POJO to a @PostMapping
using a RestTemplate
@Data
public class Form{
private Long customMetaData;
private String moreCustomMetaData;
private Date evenMoreCustomMetaData;
private MultipartFile file;
}
Which gets populated by
<form enctype="multipart/form-data">
<input name = "customMetaData" type="text">
<input name = "moreCustomMetaData" type="text">
<input name = "evenMoreCustomMetaData" type="text">
<input name = "file" type="file">
</form>
which gets posted by
HttpHeaders headers= new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<U> httpEntity = new HttpEntity<>(from, headers);
restTemplate.exchange(restUri + path, method, httpEntity, responseType);
to
@PostMapping
public ResponseEntity<Long> postForm(@RequestBody From form){
return ResponseEntity.ok(-1L)
}
but I keep getting
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer