From 9a434bfa62168ae13e5f64ee4b67380708831b51 Mon Sep 17 00:00:00 2001 From: DigitalSonic Date: Wed, 3 Jul 2019 00:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=90=E4=BA=A4items?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../geektime/spring/springbucks/customer/CustomerRunner.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Chapter 8/hateoas-customer-service/src/main/java/geektime/spring/springbucks/customer/CustomerRunner.java b/Chapter 8/hateoas-customer-service/src/main/java/geektime/spring/springbucks/customer/CustomerRunner.java index 01fcc9ac..20f26082 100644 --- a/Chapter 8/hateoas-customer-service/src/main/java/geektime/spring/springbucks/customer/CustomerRunner.java +++ b/Chapter 8/hateoas-customer-service/src/main/java/geektime/spring/springbucks/customer/CustomerRunner.java @@ -21,6 +21,7 @@ import org.springframework.web.client.RestTemplate; import java.net.URI; +import java.util.Collections; @Component @Slf4j @@ -85,7 +86,7 @@ private void addOrder(Link link, Resource coffee) { Resource order = resp.getBody(); Link items = order.getLink("items"); - req = RequestEntity.post(items.getTemplate().expand()).body(coffee.getLink("self")); + req = RequestEntity.post(items.getTemplate().expand()).body(Collections.singletonMap("_links", coffee.getLink("self"))); ResponseEntity itemResp = restTemplate.exchange(req, String.class); log.info("add Order Items Response: {}", itemResp); }