Posted over 8 years ago. Visible to the public. Repeats. Linked content.

How to send HTTP requests using cURL

  • Reading a URL via GET:

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

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

    Copy
    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:

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

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

Check the man page for more features.

If you are looking for curl-like functionality for an IRB or Rails console, take a look at the rest-client gem.

If you prefer having a GUI, take a look at the Chrome extension Postman.

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
almost 2 years ago
by Arne Hartherz
Keywords:
linux, unix
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more