I try send request via RestClient:
fun uploadFile(file: MultipartFile): MyDtoRs {
val resource: Resource = file.resource
val parts = LinkedMultiValueMap<String, Any>()
parts.add("file", resource)
val httpHeaders = HttpHeaders()
httpHeaders.contentType = MediaType.MULTIPART_FORM_DATA
val httpEntity = HttpEntity(parts, httpHeaders)
val restClient = RestClient.create()
return restClient.post()
.uri("my/url")
.body(httpEntity)
.retrieve()
.toEntity(MyDtoRs::class.java)
.body!!
}
I get an error
"Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException:No serializer found for class sun.nio.ch.ChannelInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.http.HttpEntity["body"]->org.springframework.util.LinkedMultiValueMap["file"]->java.util.ArrayList[0]->org.springframework.web.multipart.MultipartFileResource["inputStream"])"
Spring Boot version 3.3.2 I found solve for RestTemplate: How to send Multipart form data with restTemplate Spring-mvc - it work only for RestTemplate and not RestClient
Comment From: bclozel
Can you share a minimal sample?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.