【发布时间】:2021-08-11 15:20:15
【问题描述】:
我正在通过 HttpClient 进行 GET REST 调用:
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(endpoint))
.GET()
.header("Authorization", authHeader)
.header("Content-Type", "application/json")
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
如何在 MyObject 对象中映射响应?首先将其作为字符串拦截是否正确?另外,我需要传递一个字符串作为路径参数,但我不知道在哪里添加它。
感谢支持!!
【问题讨论】:
标签: java json rest get httpclient