Unable to access request body using getBodyAsJson() in Vert.X 3.0.0

6.8k Views Asked by At

I am using Vert.x 3.0.0-milestone5, to develop a sample web application. Everything is working fine as far as the routing is concerned, but I am not able to access request parameters using routingContext.getBodyAsJson() or routingContext.getBody() or routingContext.getBodyAsString(). Here is the complete description.

2

There are 2 best solutions below

1
On

If you want to use

routingContext.getBody();
routingContext.getBodyAsJson();

You first need to add a body handler like below:

router.route().handler(BodyHandler.create());
0
On

In new version of Vert.x these methods are Deprecated: link

So, you need to use body();. Or add this tag before @Deprecated

@Deprecated
routingContext.getBody();
routingContext.getBodyAsJson();

Reference: Here