Besi
Besi

Reputation: 22939

Curl command for issuing a POST request

I am in my Terminal and I want to send a POST request to a given URL. I have tested this with a REST client so I know that the parameters work.

So lets say I want to POST the following parameters:

To my URL: https://exmaple.com/login/

I tried the following curl command in my Terminal (I am using OSX Lion)

curl --data "username=tony&password=secret" http://exmaple.com/login/

I get an 500 Server Error back from the server so I am now thinking of something that could be different between the REST Client and the curl command.

Thanks for your help

Update: I am using a https service. Do I have to adjust my curl command to account for this?

Upvotes: 28

Views: 59956

Answers (1)

russau
russau

Reputation: 9108

Try this

curl -F username=tony -F password=secret http://exmaple.com/login/

-F (reference) should probably do the same as --data? Possible the problem is in the webapp.

Maybe the app you are hitting uses basic auth for authentication? Try this one:

curl --user name:password http://exmaple.com/login/

Upvotes: 23

Related Questions