title: Getting String body from Spring serverrequest
body: <p>I am trying to get simple string from request body but keep getting errors</p>
  
  <p>Handler:</p>
  
  <pre><code>@RestController
  
  public class GreetingHandler {
  
  
      public Mono&lt;ServerResponse&gt; hello(ServerRequest request) {
  
          String contentType = request.headers().contentType().get().toString();
  
          String body = request.bodyToMono(String.class).toString();
  
          return ServerResponse.ok().body(Mono.just("test"), String.class);
  
  
  
      }
  }
  </code></pre>
  
  <p>Router:</p>
  
  <pre><code>@Configuration
  public class GreetingRouter {
  
      @Bean
      public RouterFunction&lt;ServerResponse&gt; route(GreetingHandler greetingHandler) {
  
         return RouterFunctions
                  .route(RequestPredicates.POST("/hello"),greetingHandler::hello);
  
  
      }
  }
  </code></pre>
  
  <p>Request works i can see the contenType (plainTexT) and i get the response in postman but no way i cant get to request body. The most common error i get is MonoOnErrorResume. How do i convert the body from request into String? </p>