Tuesday 29 November 2016

cURL it !!

curl

In this post I would like to highlight how you can setup and use one of the powerful tool curl in windows machine. Out of many features, I found curl very useful while testing rest/soap services. 

cURL is a command line tool for getting or sending files using URL syntax.
It supports a range of common Internet protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DAP, DICT, TELNET etc.

You can download the software from below location:


Installation is very easy in windows.

1.       Extract the zip file and keep it in a location in your computer.
2.       Go to http://curl.haxx.se/docs/caextract.html and download the digital certificate file named ca-bundle.crt.

Machine generated alternative text:
Computer 
Local Disk REST 
curl 
New folder 
Include in library 
Name 
Share with 
mloads 
curl.exe 
curl-ca-bundle.crt


3.       Add the curl folder path to your Windows PATH environment variable so that the curl command is available from any location at the command prompt.

Testing with curl command

I mainly used this during some activity related to salesforce. So example urls can be different in your case. Now you are ready to get your hands dirty ;-)

a.       Open command prompt and type :- 

b.      In proxy enabled system ,you may get Timed out issue.

c.       Curl support proxy so you can type the command above like below

                                    i.     curl https://ap1.salesforce.com/services/data -H "X-PrettyPrint:1" --proxy <proxy_name>:<port> --proxy-user <proxy_user>:<proxy_user_credential>

                                     ii.            In above command -H "X-PrettyPrint:1" is added to get the output in formatted way. You can test the output without that part to get the clear idea.


d.      You may face the certification issue while executing the above command. In development environment you can skip this part by adding -k after curl command. For example-

                                                 i.   curl -k https://ap1.salesforce.com/services/data -H "X-PrettyPrint:1" --proxy <proxy_name>:<port> --proxy-user <proxy_user>:<proxy_user_credential>


e.      For help or other usage you can simply type the command curl --help


Hope this will be helpful... :-)



Note: Blogs which I have written are totally my personal view based on my personal experience.

No comments:

Post a Comment

Make life easier — Git automation with single command file

Make life easier — Git automation with single command file Posted on medium #makelifeeasier series - Automation of git related activity...