dimanche 25 octobre 2020

How to restremplate to deletemapping with requestbody of list of objects

I am trying to connect an endpoint which is in other profile and it defined as following:

 @DeleteMapping("/persons")
    public ResponseEntity<Boolean> deletePersons(@RequestBody List<Persons> persons) {

I send a resttemplate as following but it does not work:

 public ResponseEntity<Boolean> deletePersons(List<Persons> persons) {
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Collections.singletonList(MediaType.APPLICATION_OCTET_STREAM));
        HttpEntity<?> httpEntity = new HttpEntity<>("persons", headers);

        return restTemplate.exchange(url, HttpMethod.DELETE, httpEntity, Boolean.class,
            persons);
    }

i am getting the following error:

No HttpMessageConverter for java.lang.String



Aucun commentaire:

Enregistrer un commentaire