Read more

How to send HTTP requests using cURL

Arne Hartherz
April 08, 2011Software engineer at makandra GmbH
  • Reading a URL via GET:

    curl http://example.com/
    
  • Defining any HTTP method (like POST or PUT):

    curl http://example.com/users/1 -XPUT
    
  • Sending data with a request:

    curl http://example.com/users -d"first_name=Bruce&last_name=Wayne"
    

    If you use -d and do not set an HTTP request method it automatically defaults to POST.

  • Performing basic authentication:

    curl http://user:password@example.com/users/1
    
  • All together now:

    curl http://user:password@example.com/users/1 -XPUT -d"screen_name=batman"
    

Check the man page Show archive.org snapshot for more features.

Read more

  • You can also use Cookies with cURL.
  • If you are looking for curl-like functionality for an IRB or Rails console, take a look at the rest-client Show archive.org snapshot gem.
  • If you prefer having a GUI, take a look at the Chrome extension Postman Show archive.org snapshot .
  • In the Network tab of Chrome Dev tools you can right-click a request and choose Copy / Copy as cURL. This copies an cURL CLI line into your clipboard that corresponds to the request.
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot
Posted by Arne Hartherz to makandra dev (2011-04-08 09:30)