HTTP POST with curl

June 29, 2005 · Posted in Computer 

I keep forgetting how to perform a HTTP POST with curl, so I want to write this down so I don’t forget.

Posting a string:

curl -d “String to post” “http://www.domain.com/file.php”

Posting the contents of a file

curl -d @file_to_post.txt “http://www.domain.com/file.php”

Bookmark and Share

Comments

9 Responses to “HTTP POST with curl”

  1. MMORPG Forums - Runescape World of Warcraft on November 8th, 2008 12:37 am

    thanks for the cron code

  2. ch on November 22nd, 2008 1:19 pm

    thanks for posting.. exactly what I was looking for :)

  3. andy on November 30th, 2008 11:46 am

    Thats right, I’m gonna try it out right now and comment how its going

  4. andy on November 30th, 2008 11:49 am

    I tried out but with no success, I might have to pass my password and user name to be able to , I guess….
    Does any body knows how to pass password and user name while posting with curl?
    Thanks for any hint!
    andy

  5. Josh on February 16th, 2009 10:04 am

    curl -u “username:password” http://www.whatever.com/whatever
    - or -
    curl http://username:password@www.whatever.com/whatever
    If it’s a site with a self-signed cert and you have to connect over https, you may have to add the –insecure (I think the short version is -k but don’t quote me on that) option to keep curl from yelling at you about certificate mismatches.

  6. Bentos on May 18th, 2009 12:26 am

    In some cases, xml-based web service API’s require this header in order to work:
    -H “Content-Type: text/xml” . Placed after the data and before the url, of course:

    curl –silent –data-ascii “${myrequest}” -H “Content-Type: text/xml” http://${myxmlservice}

  7. peko on June 24th, 2009 4:03 pm

    Thank you very much, it was very useful for me :)

  8. Smily on November 4th, 2009 8:22 am

    Interesting way to not lose track, I have one file were I stick all code related snippets that I might need later, its getting a little large, maybe it is time for a new strategy:)

  9. [...] HTTP POST with curl [...]

Leave a Reply