Reputation: 86727
I want to make a restful webservice call to http://www.cleartrip.com/places/hotels/info/41748
How can I form dynamic properties in the request string? The following is what I tried and does not work:
Client client = ClientBuilder.newClient();
client.property("hotelnr", 41748);
//works not (HTTP 404 Not Found):
client.target("http://www.cleartrip.com/places/hotels/info/{hotelnr}").request(MediaType.APPLICATION_XML).get();
//works:
client.target("http://www.cleartrip.com/places/hotels/info/41748").request(MediaType.APPLICATION_XML).get();
Upvotes: 0
Views: 522
Reputation: 3065
Take a look in: http://docs.oracle.com/javaee/7/tutorial/doc/jaxrs-client001.htm#sthref1397
You can do as follows:
WebTarget myResource = client.target("http://example.com/webapi/read")
.path("{userName}");
Response response = myResource.queryParam("userName", "janedoe")
.request(...)
.get();
Upvotes: 4