Spring Boot Rest API HttpMediaTypeNotSupportedException

时间:2018-07-17 19:59:09

标签: spring-boot

@PostMapping(value ="/user", consumes={MediaType.MULTIPART_FORM_DATA_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public ApplicationUser createClient(@RequestBody @Valid ApplicationUserDto input,
                                    @RequestParam(required = false) MultipartFile logo) {
    return svc.registerNewClient(input, logo);
}

当我尝试从swagger-ui对其进行测试时,org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=---------------------------158650901010513877241477242870;charset=UTF-8' not supported

我想念什么吗?

因为api可以正常工作:

    @PostMapping(value ="/user")
    @ResponseStatus(HttpStatus.CREATED)
    public ApplicationUser createClient(@RequestBody @Valid ApplicationUserDto input) {
        return svc.registerNewClient(input);
    }

@PostMapping(value ="/user")
@ResponseStatus(HttpStatus.CREATED)
public ApplicationUser createClient(@RequestParam MultipartFile logo) {
    return svc.registerNewClient(logo);
}

0 个答案:

没有答案