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

Now that we know how to send payload to a server using cURL, let's create a new book resource item:

$ curl -H "Content-Type: application/json" -LX POST -d '{"title":"Ultra New Book", "link": "Ultra New Link"}' localhost:8080/api/books/ | jq # POST ie., create a new resource. 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100   111  100    59  100    52    99k  89655 --:--:-- --:--:-- --:--:-- 59000 
{ 
  "id": "6", 
  "title": "Ultra New Book", 
  "link": "Ultra New Link" 
} 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100    46  100    46    0     0   8234      0 --:--:-- --:--:-- --:--:--  9200 
100   301  100   301    0     0  46414      0 --:--:-- --:--:-- --:--:-- 46414 
[ 
  { 
 "id": ...

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