Skip to content

Commit 3a21a8c

Browse files
committed
ApacheHttp client
1 parent ed67699 commit 3a21a8c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Java-RESTful-Client-Example/src/main/java/com/howtoprogram/service/BookRepositoryImplApacheHttpClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public Book updateBook(Book book) {
5151
httpclient.start();
5252
// Create a HttpPut instance.
5353
HttpPut request = new HttpPut(URI_BOOK + "/" + book.getId());
54+
request.setHeader("Content-type", "application/json");
5455
// Create new instance of ObjectMapper
5556
ObjectMapper mapper = new ObjectMapper();
5657
String jsonBook = mapper.writeValueAsString(book);
@@ -85,6 +86,7 @@ public Book createBook(Book book) {
8586
httpclient.start();
8687
// Create a delete method instance.
8788
HttpPost request = new HttpPost(URI_BOOK);
89+
request.setHeader("Content-type", "application/json");
8890
// Create new instance of ObjectMapper
8991
ObjectMapper mapper = new ObjectMapper();
9092
String jsonBook = mapper.writeValueAsString(book);

0 commit comments

Comments
 (0)