我将发布此帖子,但我也想设置我希望收到回复的语言。

final String language = metadata.getLanguage(); //this is the string i want to send with the post
final String baseUrl = getProperty(BASE_URL_PROPERTY);

final Client client = ClientBuilder.newClient();
final WebTarget target = client.target(baseUrl);
final WebTarget template = target.path("myURI");
final Invocation.Builder invocationBuilder = template.request(MediaTypes.ORDER_REQUEST_JSON);

final Response response = invocationBuilder.post(Entity.json(orderRequest));


您能以某种方式帮助我将语言附加到请求中吗?
谢谢!

最佳答案

简单:

final Invocation.Builder invocationBuilder = template.request(MediaTypes.ORDER_REQUEST_JSON).acceptLanguage(language);

07-24 19:21
查看更多