【发布时间】:2020-12-10 11:04:05
【问题描述】:
String url = "https://localhost:8080/api/V1/hr/Auth";
HttpClient client = httpClientFactory.getHttpClient();
HttpPost request = new HttpPost(url);
request.addHeader("content-type", "application/json");
request.addHeader("clientUniqueId", "");
request.addHeader("language", "English");
jsonObject.put("UserName", "");
jsonObject.put("Password", "");
StringEntity params = new StringEntity(jsonObject.toString());
request.setEntity(params);
HttpResponse response;
response = client.execute(request);
String responseAsString = EntityUtils.toString(response.getEntity());
我需要用 WebClient 替换 httpClient 我使用了 webflux 依赖项。 并尝试过
HttpRequest request1 = (HttpRequest) webClientBuilder
.build()
.post()
.uri(url)
.header("content-type", "application/json")
.header("clientUniqueId", "")
.header("language", "English");
提前致谢。
【问题讨论】:
标签: java spring spring-boot spring-webclient