Making REST API Requests with cURL as a CLI (command line interface) – here are a few cURL argument we’ll pass with our requests

Making REST API Requests with cURL as a CLI (command line interface) – how to do GET, POST, PUT, PATCH, and DELETE requests via cURL

GET Request
curl https://jsonplaceholder.typicode.com/posts
curl -i https://jsonplaceholder.typicode.com/posts
POST Request
curl -X POST -d „userId=5&title=Stuff and Things&body=An amazing blog post about both stuff and things.“ https://jsonplaceholder.typicode.com/posts
curl -X POST -H „Content-Type: application/json“ -d ‚{„userId“: 5, „title“: „Stuff and Things“, „body“: „An amazing blog post about both stuff and things.“}‘ https://jsonplaceholder.typicode.com/posts
PUT Request
curl -X PUT -d „userId=1&title=Something else&body=A new body“ https://jsonplaceholder.typicode.com/posts/1
curl -X PUT -H „Content-Type: application/json“ -d ‚{„userId“: 1, „title“: „Something else“, „body“: „A new body“}‘ https://jsonplaceholder.typicode.com/posts/1
PATCH Request
curl -X PATCH -d „title=’Only change the title'“ https://jsonplaceholder.typicode.com/posts/1
curl -X PATCH -H „Content-Type: application/json“ -d ‚{„title“: „Only change the title“}‘ https://jsonplaceholder.typicode.com/posts/1
DELETE Request
curl -X DELETE https://jsonplaceholder.typicode.com/posts/1

Leave a Reply

You must be logged in to post a comment.