I'd like to make a POST request from angular whereas the backend developer's waiting for a spring boot request like this, with 3 params :
@PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<?> importFile(
@RequestParam(value = "type") Dto dto,
@RequestParam(value = "booleanValue", required = false) Boolean booleanValue,
@RequestParam("file") MultipartFile file)
throws IOException {
In Angular side I'm trying to build a form data, but I'm unable to add the boolean when I write this :
importFile(fileToImport: FileToImport, booleanValue?: boolean) {
const formData = new FormData();
formData.append('type', fileToImport.type);
formData.append('booleanValue', booleanValue);
formData.append('file', fileToImport.file);
return this.http.post('/import', formData);
}
force has got an error : Argument of type 'boolean' is not assignable to parameter of type 'string | Blob'
So how can I put 3 arguments to respect the backend ?
Thanks for your help
FileToImporttype?