Curl is one of the best utilities for HTTP based testing. So, naturally, it’s a great for REST based services which are built on top of HTTP.
If you want to do HTTPS testing but not validate the certificate use
For basic auth, use
For a url form encoded post use
-d "foo=bar". If you just want to test out a post, use an empty string like
For debugging, use
Here’s a sample command I regularly use with a combination of the options above.
curl -k --user admin:admin https://localhost:9443/bam/ -v * About to connect() to localhost port 9443 (#0) * Trying 127.0.0.1... connected * successfully set certificate verify locations: * CAfile: /opt/local/share/curl/curl-ca-bundle.crt CApath: none * SSLv3, TLS handshake, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS handshake, Server key exchange (12): * SSLv3, TLS handshake, Server finished (14): * SSLv3, TLS handshake, Client key exchange (16): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSL connection using DHE-RSA-AES256-SHA * Server certificate: * subject: C=US; ST=CA; L=Mountain View; O=WSO2; CN=localhost * start date: 2010-02-19 07:02:26 GMT * expire date: 2035-02-13 07:02:26 GMT * common name: localhost (matched) * issuer: C=US; ST=CA; L=Mountain View; O=WSO2; CN=localhost * SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway. * Server auth using Basic with user 'admin' > GET /bam/ HTTP/1.1 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.22.0 (x86_64-apple-darwin10.8.0) libcurl/7.22.0 OpenSSL/1.0.0e zlib/1.2.5 libidn/1.22 > Host: localhost:9443 > Accept: */* > < HTTP/1.1 200 OK < Date: Wed, 13 Jun 2012 06:52:01 GMT < Content-Type: text/plain < Content-Length: 14 < Server: WSO2 Carbon Server < * Connection #0 to host localhost left intact * Closing connection #0 * SSLv3, TLS alert, Client hello (1): My Sample Text