I make an HTTP GET request. My code is -
我发出HTTP GET请求。我的代码是 -
// Set basic authentication
HttpAuthenticationFeature feature = basicAuth(basicUser, basicPassword);
SSLContext sslContext= getSSLContext();
WebTarget webTarget = newRestClient(feature, sslContext, url);
Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON_TYPE);
invocationBuilder = invocationBuilder.header(key, requestHeaders.get(key));
final Response response = invocationBuilder.get();
Is there any way I can use the invocation builder to add path variables like NEW_PARAM in url/NEW_PARAM?
有什么办法可以使用调用构建器在url / NEW_PARAM中添加NEW_PARAM等路径变量吗?
1 个解决方案
#1
0
Supply it with an url
of the form url/{param}
, and then you can do:
使用url / {param}形式的url提供它,然后你可以:
webTarget = webTarget.resolveTemplate("param", "my-value");
In your example, you can just chain that method like so:
在您的示例中,您可以像这样链接该方法:
WebTarget webTarget = newRestClient(feature, sslContext, url)
.resolveTemplate("templateName", "my-value");
#1
0
Supply it with an url
of the form url/{param}
, and then you can do:
使用url / {param}形式的url提供它,然后你可以:
webTarget = webTarget.resolveTemplate("param", "my-value");
In your example, you can just chain that method like so:
在您的示例中,您可以像这样链接该方法:
WebTarget webTarget = newRestClient(feature, sslContext, url)
.resolveTemplate("templateName", "my-value");