Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3643

Content type 'multipart/form-data;boundary=----WebKitFormBoundary...' not supported Spring

$
0
0

Spring 5.0.7: MVC, Data, Security. I configure multipartResolver.

I send next Ajax request:

$.ajax({    type: 'POST',    cache: false,    processData: false,    contentType: false,    url: '/api/v1/category/add',    data: new FormData(form)}).done(result=>{console.log(result);}).fail(result=>{    console.error('ERROR:', result.responseJSON.httpStatus, result.responseJSON.message, result);    self.toast.error('API Error.');});

But there is an error: Content type 'multipart/form-data;boundary=----WebKitFormBoundary6xBCDjCtYYuUVR5c' not supported

why? i don't understand why error happen.

Controller:

@RestController@Secured("hasRole('ADMIN')")@RequestMapping(value = "/api/v1")public class ApiController {    private static final Logger LOGGER = LogManager.getLogger(ApiController.class);    @PostMapping(value = "/category/add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)    private Response categoryAdd(Response response, @RequestBody CategoryAddForm categoryAddForm) {        LOGGER.info(categoryAddForm.toString());        return response;    }}

CategoryAddForm:

public class CategoryAddForm {    private String name;    private String description;    private MultipartFile preview;    public CategoryAddForm() { }    public CategoryAddForm(String name, String description, MultipartFile preview) {        this.name = name;        this.description = description;        this.preview = preview;    }    public String getName() {        return name;    }    public String getDescription() {        return description;    }    public MultipartFile getPreview() {        return preview;    }}

I do not know what else to write, but SO requires more text. (


Viewing all articles
Browse latest Browse all 3643

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>