title: JSON parse error: Cannot construct instance of `` no String-argument constructor/factory method to deserialize from String value
body: <p>I'm having trouble to find out what I'm doing wrong in my below code to make the client consume the rest service.
  I want to send json instead of person object and return the response the same way.</p>
  
  <p>My caller service is as follow: </p>
  
  <pre><code>@Component
  public class CallRestService implements CommandLineRunner {
  
  @Autowired
  private RestTemplate restTemplate;
  
  private void callRestService() {
  
      // create a request body
      String requestBody = "{\"id\":\"1\",\"firstName\":\"replacedFirstName\",\"lastName\":\"replacedLastName\", \"age\":30}";
  
      // set headers 
      HttpHeaders headers = new HttpHeaders();
      headers.setContentType(MediaType.APPLICATION_JSON   );
      HttpEntity&lt;String&gt; entity = new HttpEntity&lt;String&gt;(requestBody, headers);
  
      //send the request
      Object response1 = restTemplate.postForObject("http://localhost:8080/person/1", entity, Object.class);
      System.out.println("Person's details are: " + response1);
  
  }
  
  @Override
  public void run(String... args) throws Exception {  
      callRestService();  
  
  }
  }
  </code></pre>
  
  <p>My consumed rest service controller is as follow: </p>
  
  <pre><code>@RestController
  @RequestMapping("/person")
  public class PersonController {
  
  
  @Autowired
  PersonService personService;
  
  @GetMapping("/all")
  public Hashtable&lt;String, Person&gt; getAll(){
      return personService.getAll();
  }
  
  @GetMapping("/{id}")
  public Person getPerson(@PathVariable("id") String id) {
      return personService.getPerson(id);
  }
  
  @PostMapping("/{id}")
  public Person setPerson(@PathVariable("id") String id, @RequestBody Person person) {
  
      Person updatedPerson = personService.getPerson(id);
      updatedPerson.setFirstName(person.getFirstName());
      updatedPerson.setLastName(person.getLastName());
  
      return updatedPerson;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My person class in my service is as follow: </p>
  
  <pre><code>public class Person {
  
  String id;
  String firstName;
  String lastName;
  int age;
  
  ...// getters and setters
  }
  </code></pre>
  
  <p>Can anyone tell me what's the mistake I'm doing to get this message error? </p>
  
  <pre><code>Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `com.rest.model.Person` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('{"id":"1","firstName":"replacedFirstName","lastName":"replacedLastName", "age":30}'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.rest.model.Person` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('{"id":"1","firstName":"replacedFirstName","lastName":"replacedLastName", "age":30}') at [Source: (PushbackInputStream); line: 1, column: 1]
  </code></pre>
  
  <p><strong>EDITED</strong>
  Here's my restTemplate configuration with the mapper:</p>
  
  <pre><code>@Configuration
  public class RestConfiguration {
  
  @Autowired
  private ObjectMapper objectMapper;
  
  @Bean
  public RestTemplate createRestTemplate() { 
   objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
      RestTemplate restTemplate = new RestTemplate();
      List&lt;HttpMessageConverter&lt;?&gt;&gt; messageConverters = new ArrayList&lt;&gt;();
      MappingJackson2HttpMessageConverter jsonMessageConverter = new MappingJackson2HttpMessageConverter();
      jsonMessageConverter.setObjectMapper(objectMapper);
      messageConverters.add(jsonMessageConverter);
      restTemplate.setMessageConverters(messageConverters);
      return restTemplate;
  }   
  }
  </code></pre>