1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | var putJson="data"; HttpRequest request = HttpRequest.newBuilder() .uri( URI.create( "http://127.0.0.1/order/save")) .header( "Authorization", "Bearer 12356556898921") .header("Content-Type", "application/json;charset=UTF-8") .method("PUT", HttpRequest.BodyPublishers.ofString(putJson)) .build(); httpclient .sendAsync(request, HttpResponse.BodyHandlers.ofString()) .thenApply(HttpResponse::body) .thenAccept(System.out::println) .join(); |