Reputation: 2459
Assume that:
WebTarget target = client.target("http://www.someurl.com");
target.queryParam("id", "1").request().post();
And when a request is done on that target, how do I get the full URL which is http://www.someurl.com?id=1 using the Jersey api?
Upvotes: 1
Views: 4097
Reputation: 208944
The thing is, if you look at the javadoc for WebTarget
, you will see that most of the method calls on WebTarget
return a new WebTarget
instance. So when you do
WebTarget target = client.target("http://www.someurl.com");
target.queryParam("id", "1").request().post();
System.out.println(target.getUri());
The target
instance is not the same instance that the query parameter is added to. So you would need to either do
WebTarget target = client.target("http://www.someurl.com");
WebTarget newTarget = target.queryParam("id", "1");
newTarget.request().post();
System.out.println(newTarget.getUri());
Or
WebTarget target = client.target("http://www.someurl.com").queryParam("id", "1");
target.request().post();
System.out.println(target.getUri());
Upvotes: 2