I have a POJO given below which I want to PUT to the server as JSON or XML.
This is what I have done
CLIENT:
ClientConfig co
There are two different Jersey major versions, 1.x and 2.x, You seems to be trying to use a combination of both, which won't work. The 2.x versions don't have some classes as in 1.x and vice versa.
If you want to use Jersey 2.x, then you should be using Response, rather than ClientResponse
Response response = target.request().put(Entity.json(friend));
// .json == automatic 'application/json'
Friend
classBasic breakdown.
Calling request()
on WebTarget
returns an Invocation.Buidler
Invocation.Builder builder = target.request();
Once we call put, we get back a Response
Response response = builder.put(Entity.json(friend));
To extract a known type from the response, we could use readEntity(Class type)
String responseString = response.readEntity(String.class);
response.close();