Posted about 10 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.

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

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

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
5 months ago
by Judith Roth
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 short-lived cookies to improve usability.
Accept or learn more