The following solution updates the email address of the user we fetched in the preceding subsection:
user.getData().setEmail("[email protected]");
HttpRequest requestPut = HttpRequest.newBuilder()
.header("Content-Type", "application/json")
.uri(URI.create("https://reqres.in/api/users"))
.PUT(HttpRequest.BodyPublishers.ofString(jsonb.toJson(user)))
.build();
HttpResponse<User> responsePut = client.send(
requestPut, JsonBodyHandler.jsonBodyHandler(jsonb, User.class));
User updatedUser = responsePut.body();