Thursday, November 20, 2014

Linux - curl example

Recently was asked to try a curl by a team mate. 
Turns out it was kinda ugly and I had to use:
  • cookies
  • body
  • header
  • redirect
 This is what it ended up looking like:

curl -b cookies.txt -c cookies.txt -L -v -H "Content-Type:application/x-www-form-urlencoded" --data 'login_fail_url=http://junksample.com/damnitall&login_success_url=http://junksample..com/woopeedoo' 'http://junksample.com/v1/login'

the "-L" portion told curl to follow the 302 redirect that comes back
the "-b cookies.txt -c cookies.txt" portion stored a cookie that came back and then used the cookie when it followed the redirect
the "-H ...." portion was for adding a header
the "--data ...." portion was for specifying the POST body

No comments:

Post a Comment