How to send HTTP requests using cURL

Updated . Posted . Visible to the public.
  • 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

Arne Hartherz
Last edit
Dominik Schöler
Keywords
linux, unix
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2011-04-08 07:30)