1

I am working with node-red and I want to send N files to my java controller with spring boot (it is of type MultipartFile[]). However, it always goes to null. I have tried to use a function to enter the input DTO as seen in the image, but it has not worked. I have also tried using the multipart-form-data node but it fails to launch the request. Is there any idea why I am getting null for the attachments attribute in my controller?

This is my controller, which debugging, attachments value is null.

@PostMapping
public ResponseEntity<String> post(@RequestParam(required = false, value = "attachments") MultipartFile[] attachments) {
    return new ResponseEntity<String>("OK!!!", HttpStatus.OK);
}

That is my node red scheme, where I receive a mail, I pass it to the 'parse to attachments' function and it goes to an http request, which is a post request connected to my service locally

enter image description here

This is the function:

enter image description here

I have also changed it for this function, but it still does not work enter image description here

Debug-node works correctly, it shows meta info about attachments.

UPDATE:

I used http-send-multipart-formdata node, but still not working. enter image description here I checked with debug-node that attachments[0] is filled.

I changed MultipartFile[] by MultipartFile. I tried too changing value 'attachments' in my controller by 'documentDTO', but documentDTO is null. Why can't I fill this attribute in that node? This is my controller:

@PostMapping
    public ResponseEntity<DocumentDTO> create(@RequestParam MultipartFile documentDTO) {
        if (documentDTO != null) {
            System.out.println("FILLED!");
        }
        return null;
    }
Talenel
  • 422
  • 2
  • 6
  • 25

0 Answers0