Implementing a CXF JAX-RS client with JSON request

122 views Asked by At

I am trying to develop a client where i will perform a POST operation and pass a json in the service request.

Checking CXF's official documentation i found the code snippet below:

Client client = ClientBuilder.newBuilder().newClient();
WebTarget target = client.target("http://localhost:8080/rs");
target = target.path("service").queryParam("a", "avalue");
 
Invocation.Builder builder = target.request();
Response response = builder.get();
Book book = builder.get(Book.class);

I understand that the request here is "a", "avalue". How can i tweak this code in order to pass a json string as the request?

0

There are 0 answers