Kein geeignetes HTTPMessageConverter für Antworttyp und Inhaltstyp [Application/JSON; Charset = UTF-8] tritt aufJava

Java-Forum
Guest
 Kein geeignetes HTTPMessageConverter für Antworttyp und Inhaltstyp [Application/JSON; Charset = UTF-8] tritt auf

Post by Guest »

Ich versuche, in meinem anderen Modul der Anwendung den Frühlingsrückendpunkt zu treffen. Ich versuche also, die REST -Vorlage zu verwenden, um eine Liste von Benutzern wie unten zu erhalten: < /p>

Die API -Anforderung mit REST -Vorlage: < /p>

Code: Select all

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>

LeaduserList -Klasse: < /p>

public class LeadUserList {

private List usersList;

public List getUsersList() {
return usersList;
}
}
< /code>

Bleimodellklasse: < /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>

Die API -Endpunkt -Controller -Klasse: < /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>

Obwohl der Rückgabetyp JSON aus dem API -Endpunkt ist, erhalten Sie die obige Ausnahme. Was habe ich hier falsch gemacht? < /p>

Die Ausnahme: < /p>

Could not extract response: no suitable HttpMessageConverter found for response type [class admin.client.domain.LeadUserList] and content type [application/json]

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post