public static void updateDoctorByAdmin(int id) throws JsonProcessingException { doctor.setId(id); doctor.setName("Valera"); speciality.setId(1); doctor.setSpeciality(speciality); RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.set("auth-token", StaticStrings.ADMIN_AUTH_TOKEN); HttpEntity entity = new HttpEntity(doctor, headers); HttpEntity<Response> response = restTemplate.exchange( StaticStrings.UPDATE_DOCTOR_URI, HttpMethod.POST, entity, Response.class); ObjectMapper mapper = new ObjectMapper(); System.out.println( mapper.writerWithDefaultPrettyPrinter().writeValueAsString(response.getBody())); }