How to send JSON and image to my SpringBoot Rest Controller

Viewed 33

guys, i can't find a solution to my problem. I have a RestController which applies MultipartFile(i need to send image) and Request Body(JSON).

    @PostMapping
    public ResponseEntity<Dish> saveDish(@RequestBody Dish dish, @RequestParam("file") MultipartFile file){
        Dish savedDish = dishService.save(dish, file);

        return ResponseEntity.ok(savedDish);
    }

How can i load it in postman? When you send body using row, you can load only JSON, and when you use form-data, you can load only file.

enter image description here

enter image description here

And, by the way, i get exception when try to load image. I will be very grateful if you solve my problem)

0 Answers
Related