title: Troubles posting a JSON value using Spring Boot
body: <p>I am trying to make a post request using json but in postman the request is successful only if I make the request like this: <code>email@example.com</code>. If I make a request using the standard JSON format <code>{"email":"email@example.com"}</code> I get "invalid email id". I should mention that content type <code>application/json</code> header is checked in postman, and I am making the request in body/raw.</p>
  
  <p>I have tried messing with <code>@RequestBody</code>/<code>@RequestParam</code> annotations, using <code>consumes = "application/json"</code> but I am unsuccessful and I couldn't find a similar issue after lots of googling either. </p>
  
  <p>my controller:</p>
  
  <pre><code>@RestController
  public class UserController {
  
  @Autowired
  private UserService userService;
  
  @PostMapping(value = "/forgot-password", consumes = "application/json")
  public String forgotPassword(@RequestBody String email) {
  
      String response = userService.forgotPassword(email);
  
      if (!response.startsWith("Invalid")) {
          response = "http://localhost:8080/reset-password?token=" + response;
      }
      return response;
  }
  </code></pre>
  
  <p>user service:</p>
  
  <pre><code>public String forgotPassword(String email) {
  
      Optional&lt;User&gt; userOptional = Optional
              .ofNullable(userRepository.findByEmail(email));
  
      if (!userOptional.isPresent()) {
          return "Invalid email id.";
      }
  
      User user = userOptional.get();
      user.setToken(generateToken());
      user.setTokenCreationDate(LocalDateTime.now());
  
      user = userRepository.save(user);
  
      return user.getToken();
  }
  </code></pre>