Trying to Send list of string in post request using webClient in spring

Viewed 4091
  • I am trying to send a list of strings using webClient but I am getting an exception.

  • I used Flux.fromIterable(strList) but it merged all the data before sending, because of that instead of a list of strings I received combined single string on mapping class.

     List<String> str = new ArrayList<>();
                 str.add("korba");
                 str.add("raipur");
                 str.add("bhilai");
    
       Flux<Object> responsePost = webClient.build()
                          .post()
                          .uri(url)
                          .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                          .body(Flux.fromIterable(str), String.class)
                          .retrieve()
                          .bodyToFlux(Object.class);
    
1 Answers
Related