My code:
final MultiValueMap<String, String> parts = new LinkedMultiValueMap<String, String>();
parts.add( "fileName", fileName );
HttpHeaders xmlHeaders = new HttpHeaders();
xmlHeaders.setContentType( MediaType.APPLICATION_XML );
HttpEntity<Resource> xmlEntity = new HttpEntity<Resource>( new FileSystemResource( file ), xmlHeaders );
parts.add( "file", xmlEntity );
final String url = baseurl+url;
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( parts, createHttpHeadersWithToken() );
String response= restTemplate.exchange( url, HttpMethod.POST, requestEntity, String.class );
Exception
Exception occured while calling post config file: {} org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class java.nio.channels.Channels$1]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.nio.channels.Channels$1 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.util.LinkedMultiValueMap["file"]->java.util.LinkedList[0]->org.springframework.http.HttpEntity["body"]->org.springframework.core.io.FileSystemResource["outputStream"])