Я пытаюсь попасть в конечную точку Spring Rest в моем другом модуле приложения. Поэтому я пытаюсь использовать шаблон отдыха, чтобы получить список пользователей, как ниже: < /p>
Запрос API с использованием шаблона REST: < /p>
public List getUsersBySignUpType(String type, String id) {
String adminApiUrl = adminApiBaseUrl+"/crm/v1/users/?type="+type+"&id="+id;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
HttpEntity entity = new HttpEntity(headers);
ResponseEntity response = restTemplate.exchange(
adminApiUrl, HttpMethod.GET, entity, LeadUserList.class);
return response.getBody().getUsersList();
}
< /code>
class class: < /p>
public class LeadUserList {
private List usersList;
public List getUsersList() {
return usersList;
}
}
< /code>
Класс модели Leaduser: < /p>
public class LeadUser {
@JsonProperty("id")
private String id;
@JsonProperty("email")
private String email;
@JsonProperty("name")
private String name;
@JsonProperty("businessName")
private String businessName;
@JsonProperty("phone")
private String phone;
@JsonProperty("address")
private String address;
@JsonProperty("createdTime")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private Date createdTime;
@JsonProperty("updatedTime")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private Date updatedTime;
@JsonProperty("bookletSignups")
private BookletSignUp bookletSignUp;
@JsonProperty("eventSignups")
private EventSignUp eventSignUp;
@JsonProperty("infoSignups")
private InfoSignUp infoSignUp;
@JsonProperty("webinarSignups")
private WebinarSignUp webinarSignUp;
public LeadUser() {
}
}
< /code>
Класс контроллера конечной точки API: < /p>
@Controller
@Component
@RequestMapping(path = "/crm/v1")
public class UserController {
@Autowired
UserService userService;
@RequestMapping(value = "/users", method = GET,produces = "application/json")
@ResponseBody
public ResponseEntity getPartnersByDate(@RequestParam("type") String type,
@RequestParam("id") String id) throws ParseException {
List usersList = userService.getUsersByType(type);
return new ResponseEntity(usersList, HttpStatus.OK);
}
}
< /code>
Хотя тип возврата - это json из конечной точки API, я получаю вышеуказанное исключение. Что я сделал здесь не так? < /p>
Исключение: < /p>
Could not extract response: no suitable HttpMessageConverter found for response type [class admin.client.domain.LeadUserList] and content type [application/json]
Подробнее здесь: https://stackoverflow.com/questions/559 ... type-appli
Нет подходящего httpmessageConverter, не найденный для типа ответа и типа контента [Application/json; charset = utf-8] И ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение