DELETE

Assuming that we have a book with the id "2", we can delete it using cURL, as follows:

$ # We can make other method calls by providing -X flag with method name in caps. 
$ curl -LX DELETE localhost:8080/api/books/2 | jq  # DELETE a resource. 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100     2  100     2    0     0    337      0 --:--:-- --:--:-- --:--:--   400 
[] 
$ curl -L localhost:8080/api/books | jq # GET all books after resource deletion. 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100    46  100    46    0     0  21465      0 --:--:-- --:--:-- --:--:-- 46000 
100   249  100   249    0     0  91008      0 --:--:-- --:--:-- --:--:-- 91008 
[ 
  { 
    "id": "5", 
    "title": "Book-5", 
    "link": "http://link-to-book5.com" 
  }, 
  { 
    "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": "Book-4", 
    "link": "http://link-to-book4.com" 
  } 
] 
..................Content has been hidden....................

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