O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required