POST /api/books

This REST API call will create a new item of book resource type. However, in order to create a new item, we would need to provide all the necessary data. It is possible to have POST requests that do not require any extra information. But in our case, we need to send information such as the title and link to the book as request's payload.

In this example, we want to create a book item with the title "book5" and link "http://link-to-book5.com". Note that since our server already has two items of the book resource type, the new item is created with id of "3"; this is the implementation as per our server. Other REST servers might behave differently.

// Request 
POST "<URL>/api/books" 
 
// payload 
{ 
   "title": "book5", 
   "link": "http://link-to-book-5.com" 
 } 
 
 // response 
 { 
    "id": "3", 
    "title": "book5", 
    "link": "http://link-to-book-5.com" 
  } 
..................Content has been hidden....................

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