title: Spring reactive WebClient GET json response with Content-Type "text/plain;charset=UTF-8"
body: <p>I’m having an issue with Spring 5 reactive WebClient, when I request an endpoint that returns a correctly formated json response with content type "text/plain;charset=UTF-8".
  The exception is</p>
  
  <pre><code>org.springframework.web.reactive.function.UnsupportedMediaTypeException:
  Content type 'text/plain;charset=UTF-8' not supported for bodyType=MyDTOClass
  </code></pre>
  
  <p>Here is how I made the request:</p>
  
  <pre><code>webClient.get().uri(endpoint).retrieve().bodyToFlux(MyDTOClass.class)
  </code></pre>
  
  <p><strong>EDIT</strong>: Headers are "correctly" setted (Accept, Content-Type), I have tried differents content-types (json, json + UTF8, text plain, text plain + UTF8) conbinations, without success. I think the issue is <code>.bodyToFlux(MyDTOClass.class)</code> doesn't know how to translate "text" into <code>MyDTOClass</code> objects.
  If I change the request to:</p>
  
  <pre><code>webClient.get().uri(endpoint).retrieve().bodyToFlux(String.class)
  </code></pre>
  
  <p>I can read the String.</p>
  
  <p><strong>EDIT 2</strong>: The next quote is extracted from the Spring documentation
  (<a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-codecs-jackson" rel="noreferrer">https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-codecs-jackson</a>)</p>
  
  <blockquote>
    <p>By default both <code>Jackson2Encoder</code> and <code>Jackson2Decoder</code> do not support
    elements of type <code>String</code>. Instead the default assumption is that a
    string or a sequence of strings represent serialized JSON content, to
    be rendered by the <code>CharSequenceEncoder</code>. If what you need is to render
    a JSON array from <code>Flux&lt;String&gt;</code>, use <code>Flux#collectToList()</code> and encode a
    <code>Mono&lt;List&lt;String&gt;&gt;</code>.</p>
  </blockquote>
  
  <p>I think the solution is define a new Decoder/Reader in order to transform the String into MyDTOClass, but i don't know how to do it.</p>