title: Spring 5 RouterFunction status 415 with reason "Content type 'application/json' not supported"
body: <p>I am trying to use the Spring 5 Rounter Function as per following code </p>
  
  <pre><code>public class PersonHandler {
  
      private final PersonRepository repository;
  
      public PersonHandler(PersonRepository repository) {
          this.repository = repository;
      }
  
      public Mono&lt;ServerResponse&gt; listPeople(ServerRequest request) { 
          System.out.println("List people");
          Flux&lt;Person&gt; people = repository.findAll();
          return ServerResponse.ok().contentType(APPLICATION_JSON).body(people, Person.class);
      }
  
      public Mono&lt;ServerResponse&gt; createPerson(ServerRequest request) { 
          System.out.println("Insert people");
          Mono&lt;Person&gt; person = request.bodyToMono(Person.class); 
          repository.insert(person).subscribe();
          return ServerResponse.ok().build();
      }
  
      public Mono&lt;ServerResponse&gt; getPerson(ServerRequest request) { 
          System.out.println("Get people");
          String personName = request.pathVariable("name");
          Mono&lt;ServerResponse&gt; notFound = ServerResponse.notFound().build();
          Mono&lt;Person&gt; personMono = this.repository.findByName(personName);
          return personMono
                  .flatMap(person -&gt; ServerResponse.ok().contentType(APPLICATION_JSON).body(fromObject(person)))
                  .switchIfEmpty(notFound);
      }
  }
  </code></pre>
  
  <p>This is the router function </p>
  
  <pre><code>@Configuration
  public class RoutesConfiguration {
  
      @Bean
      RouterFunction&lt;?&gt; routes(PersonRepository personRepository) {
  
          PersonHandler handler = new PersonHandler(personRepository);
          return nest(path("/person"),
                  nest(accept(APPLICATION_JSON),
                          route(GET("/{id}"), handler::getPerson)
                          .andRoute(method(HttpMethod.GET), handler::listPeople)
                  ).andRoute(POST("/").and(contentType(APPLICATION_JSON)), handler::createPerson));
      }
  }
  </code></pre>
  
  <p>When I execute the curl request </p>
  
  <pre><code>curl -X POST -d {"name":"John Doe","age":20} -H "Content-Type: application/json" http://localhost:8081/person
  </code></pre>
  
  <p>However, I got the error message for the POST request</p>
  
  <pre><code>    reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.web.server.UnsupportedMediaTypeStatusException: Response status 415 with reason "Con
  tent type 'application/json' not supported"
  Caused by: org.springframework.web.server.UnsupportedMediaTypeStatusException: Response status 415 with reason "Content type 'application/json' not supported
  "
          at org.springframework.web.reactive.function.server.DefaultServerRequest.lambda$static$0(DefaultServerRequest.java:66) ~[spring-webflux-5.0.0.RELEASE
  .jar:5.0.0.RELEASE]
          at reactor.core.publisher.Mono.lambda$onErrorMap$19(Mono.java:2354) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
          at reactor.core.publisher.Mono.lambda$onErrorResume$21(Mono.java:2446) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
          at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:88) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
          at reactor.core.publisher.Operators.error(Operators.java:175) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
          at reactor.core.publisher.MonoError.subscribe(MonoError.java:52) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
  </code></pre>
  
  <p>Anyone can help to explain what is the reason for this error? Thanks</p>