title: RestTemplate does send null values in object
body: <p>I have written a very simple EmailService using Spring boot.</p>
  
  <p>A controller received an EmailRequest and sends the Mail:</p>
  
  <pre><code>@RestController
  @Slf4j
  public class EmailController {
      private final EmailService emailService;
  
      public EmailController(EmailService emailService) {
          this.emailService = emailService;
      }
  
      @PostMapping
      public ResponseEntity sendEmail(EmailRequest request) {
          try {
              emailService.sendEmail(request);
          } catch (Exception e) {
              log.error("Error while sending email", e);
              return ResponseEntity.badRequest().build();
          }
          return ResponseEntity.ok().build();
      }
  }
  </code></pre>
  
  <p>I want to test the behaviour in another controller as follows:</p>
  
  <pre><code>@Controller
  public class TestController {
      @GetMapping
      public ResponseEntity testSend(){
          EmailRequest request = new EmailRequest();
          request.setTo("roger@example.com");
          request.setBody("This is the body");
          request.setSubject("This is a subject");
          return new RestTemplate().postForObject("http://localhost:9999",request,ResponseEntity.class);
      }
  }
  </code></pre>
  
  <p>Now i set two breakpoints, one before sending the request via RestTemplate. As expected, the values are filled correctly.</p>
  
  <p>Another breakpoint in the receiving controller is showing all values of EmailRequest null.</p>
  
  <p>When I use PostMan to call the sending controller its working fine, so I probably  doing something wrong with the RestTemplate.</p>
  
  <p>Does anyone know what might be the problem?</p>