Basic Curl Examples

Posted by
curl -v -k -X $METHOD_TYPE -H "Content-Type:application/json" -H -d '{ "key": "Value" }' http://devopsunixandjava.com ---tlsv1.2 --cert

-H Request Header
$METHOD_TYPE GET,POST,PUT
-v verbose
-k This option explicitly allows curl to perform “insecure” SSL connections and transfers
-X Specifies a custom request method to use when communicating with the HTTP server
-d Input data in the form of JSON enclosed within ‘{}’ or file Input (@filename)
-cert pass certificate as part of curl request
-tlsv1.2 Forces curl to use TLS version 1.2 when connecting to a remote TLS server

Certificate (Some favours curl works with PKCS Certificate and some with private key and certificate)

curl -v -H “HeaderName:HeaderValue" http://devopsunixandjava.com --cert keystore.p12:$password

GET (by default all requests are treated as GET Request)

curl -v -k -H "Content-Type:application/json" -H -d '{ "key": "Value" }' http://devopsunixandjava.com

POST

curl -v -k -X POST-H "Content-Type:application/json" -H -d '{ "key": "Value" }' http://devopsunixandjava.com

PUT

curl -v -k -X POST -H "Content-Type:application/json" -H -d '{ "key": "Value" }' http://devopsunixandjava.com

 

Leave a Reply

Your email address will not be published.