PUT

Let's update an existing book resource with the id "4":

$ # We can use -d flag to provide payload in a Request 
$ curl -H "Content-Type: application/json" -LX PUT -d '{"title": "New Book Title", "link": "New Link"}' localhost:8080/api/books/4 | jq 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100   100  100    53  100    47  13289  11785 --:--:-- --:--:-- --:--:-- 17666 
{ 
  "id": "4", 
  "title": "New Book Title", 
  "link": "New Link" 
} 
$ curl -L localhost:8080/api/books | jq # GET all books after updating a resource 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100    46  100    46    0     0   9886      0 --:--:-- --:--:-- --:--:-- 11500 
100   241  100   241    0     0  47024      0 --:--:-- --:--:-- --:--:-- 47024 
[ 
  { 
    "id": "1", 
    "title": "Book-1", 
    "link": "http://link-to-book1.com" 
  }, 
  { 
    "id": "3", 
    "title": "Book-3", 
    "link": "http://link-to-book3.com" 
  }, 
  { 
    "id": "4", 
    "title": "New Book Title", 
    "link": "New Link" 
  }, 
  { 
    "id": "5", 
    "title": "Book-5", 
    "link": "http://link-to-book5.com" 
  } 
] 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181