0

very big problem since 48h00. with postman, absolutly no problem to post my body. return is 200. there is no authentication with concerned api. but, when i use my java-code, always 400 is returned !!!!

  String baseUrl = "myBaseUrl";
  String uri = "myUri";
  WebClient webClient = WebClient.create(baseUrl);
  ClientResponse cresponse = webClient
  .post()
  .uri(uri)
  .contentType(MediaType.APPLICATION_JSON_UTF8)
  .syncBody(myObject)
  .exchange()
  .block();

  // always 400!!!! here !!!!!!!
  System.out.println("result :" + cresponse.statusCode());
electrode
  • 205
  • 1
  • 4
  • 16

2 Answers2

0

Probably something wrong with "myObject".

johannesr
  • 21
  • 4
0

I think the problem is the way in you are feeding the body in your request. Use Mono.just to create a mono to feed the body as shown below

webClient.post().body(Mono.just(myObject)), MyObject.class).exchange().block().statusCode();

Javier
  • 11
  • 1