1

I am new to Vertx and Rx Java. I want to do a Http POST , but my content is a string. Here is my code :

Single<HttpResponse<Buffer>> single = webClient
  .post(apiUrl)          
  .rxSendStream(body);

and body can be any of the following:

  • Flowable<Buffer> body or
  • Observable<Buffer> body or
  • Buffer body

My question is how do i convert body to any of the above types

taygetos
  • 3,005
  • 2
  • 21
  • 29

1 Answers1

1

The easiest way is this:

WebClient webClient = WebClient.create(vertx);
String body  = "";
webClient.post(apiUrl)
   .rxSendBuffer(Buffer.buffer(body))
   .subscribe(resp -> {
     System.out.println(resp.body().toString());
   });
taygetos
  • 3,005
  • 2
  • 21
  • 29