How to use CURL on Windows | How to test API with CURL | CURL Basics Step by Step

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this session on call this is going to be a very basic beginner session on curl and we are going to see what is curl how to run call on Windows and then how can you run the API requests get post put and delete with curl so let's get started and let me go to my browser and here let me type curl and press enter and you will get this first website for girl let me go here so this is the website for girl and here you can see girl is a command line tool and library for transferring data with URLs so if you want to transfer any data with the help of URL you can use curl and it supports almost every protocol so this is the list of protocols that is being supported by a girl and of course curl is free and open-source so let us see how can we use curl now in case you are on Mac you can directly run the curl commands from your terminal but in case you are on Windows you will have to get curl for Windows so you can go to download and download curl for Windows from here however a better option will be if you can get the git bash so if you go to your browser and say get you will get this first site called git SCM let's go here and here you can click on this download for Windows and then you can install git that will give you a get bash now in case you want a very detailed step-by-step video on how to download get and get get best you can go to my channel on YouTube which is YouTube automation step-by-step and here let's go to the playlists and in the playlists you will find a playlist for git and github and here you can watch the third session on getting started and installing it on windows so once you have it you will find and get bash here on your system let us open this okay and here you can run your Kyle command so let me just increase the font and here you can run your Kyle comments so you can say girl - - help and we'll give you all the options that you can use with girl so there is a lot and lot you can do with girl so let us go very basic step-by-step and try to run some girl requests and to save some time I have already added some notes here so in case we just want to get only the response you just can say girl and the URL so for example I just want to say girl and HTTP let us say google.com and hit enter so here it will give me some response now in case of google.com it says the document has moved so there is some redirection and if you have to follow the redirection you can say curl and you can use the - el flag and then the URL so now you can see it has given us all the response and the page of google.com and similarly you can call any website or any HTTP URL entry it will give you the response now in case we just want to get only the headers so for that you can use the - I flag here so for example let us go to or any web site let me go to let me search for a simple REST API and I have this website ru aureus which has some sample rest ApS and we can use these in our demo so they have some fake API switch we can use for testing and for example this is a get of a single user and I can use this URL along with this URL so I will copy this URL and paste in a different browser tab and then copy this request endpoint and paste it again here and hit enter it gives me a list of the user so I can use this URL and if I go to my curl and give this URL here and hit enter so here it gives me the data and the response and I can see this is the response now if I want the response along with the headers I can use them - I flex so what I will say is I will add a - I flag here and hit enter and now you can see I have caught the response here and I have also got the headers here okay so you can get the headers like this now in case you just want only headers you can use the - - head flag or - capital I so let us do that I will say - - head and you can see we have got only the headers and I can also use the - capitalized leg and I have got the headers here the next is in case we want all the client-server interaction we can use the minus V flag which is for verbose now this is useful in case you have some issues in your equation you want to troubleshoot and you want to see exactly what is happening and what is the what is going to the server what is coming back then you can use this flag so for example I can say here - V and hit enter and now you can see it has given us all the client and server injection and in case you want to get even more details you can use the - - trace flag and for here you have to give a file where you will want to log all the details so for example you can say - - trace and you can give any file location so I can say this is log trace dot txt and hit enter and now it will log all injections in this log taste or txt file now let me see where it has saved this so I will search for log trace the dot txt and it is here let me open the file location and yes it is saved here if you open this you will get all the details logged to this file so you can see all the client and server injections here also you can use the trace s Kai flag so even more details you can get from trace as sky and I will save it in a different file and that means search for this file log trace to dot txt and this here and you can get even more details level details with the sky information in this file so this is good for troubleshooting in case you are having any issues let us go to our next option in case you want to send headers in a request then you can use the minus edge flap for example you can use something like this minus H and any header so I can say here - H which is a header and then the header information so I am giving a header except application JSON and the URL and then run it and that's it so you can use mine search flag to send any headers with your request now let us come to post now until now we were discussing all the gates now if you want to do a post we have to send that data as well so let us go back to our sample API is and let us see a post request so this is a post let me go here and you can see we are sending a data as well so the first thing is I will copy this URL and go here in a new tab and this endpoint as well and copy it here so this is the endpoint or the URL and now I have to give the data as well so in curl you can use the - D or - - data option to send the data so what I will do is I will go to my git bash again let me clear this and here I will say curl and then I will give this URL and I will give this URL here and now I have to give the data so I can use - - data or simple - D and then I can give the data here so in this case we have to give this data which is name equals Morpheus and job equals leader let me just first copy this and keep it in the notepad so here I have to say name Morpheus and job leader so I would go to my grid bash and here I can say name equals Morpheus and job equals leader and hit enter and you can see I have got the response back and it says created at this time so that means our request is successful so this is how you can use - D or - - data flag to send the response now in case you want to use the entire JSON for that you will have to use the minus X flag and tell that this is a post request so you will say call - x post and then in case you have any headers you will say - H and the headers and then you can give the URL here so for example in my case this is the URL I'll copy this the URL and then - D and you can give the entire jason within this single quotes so for example in my case this is the json so let me just copy it from here and i have to give it here of course this is not in a single line so what i will first do is let me keep it in a single line here and yes i will just copy this here and yes now this is my post request i can copy this and go to my git bash and paste it here and run it and you can see this is successful it got created at and of course i can also use the - i flare so i am getting the headers as well and you can see this is - 0 1 which is for treated successfully so this is how you can use the post now in case you want to use the put you can use the minus X put flag and the same thing so for example if you go to any put request here so this is output which is for updating so this is the URL let me just copy this URL here and here is the data that will go along with the request so it follows the same convention you can use this and instead of post it will be put and let me see the data let me change this here in the job and I will use the - I flag to get the headers as well and of course I do not need the headers here and let me copy this URL and there we go so we say call - I - X put the URL and - T and the data that we want to update so let me just copy this from here and go to my git bash and paste it here and run it and yes we are getting it is saying updated at this time and we are getting the status code 200 so that means it's successful now let us go to delete and delete is minus X flag and delete so for example let us go to our delete API so this is delete and here this is the URL so we just need to get the URL it will be simply curl - X delete and the URL I can use the - hi flag as well and let me copy this from here and go to my git bash and paste it here and let us see and we have got the HTTP code - 0 4 which is 4 no content and that means it is deleted so this is how we can use delete now I will make all these nodes and descriptions available in the description of this video so you will get everything in the description plus I will also make all these URLs that I have used here in the description so you will get all these URLs all the nodes in the description now with curl you can do a lot of things if you go to the tutorial page in the documentation you will find a lot of options and usage of curl so curl is very simple you can use call for your API testing for your FTP and for sending any data with the URLs so I hope this session was very useful and now you know what is curl and how can you use curl if you like the session give it a thumbs up and share with others and please don't forget to subscribe to this channel I will meet you soon thank you for watching
Info
Channel: Automation Step by Step
Views: 136,131
Rating: undefined out of 5
Keywords: curl on windows, curl beginner tutorial, curl basics, how to run curl command on windows, curl how to run api request, how to use curl on windows, curl how to add headers, how to run post with curl, curl how to run get request, curl how to run delete, curl how to run put, curl how to run on windows, how to test api with curl command, curl api testing, what is curl, how to run curl on windows, how to run api requests with curl, how to run curl command
Id: 8f9DfgRGOBo
Channel Id: undefined
Length: 14min 39sec (879 seconds)
Published: Wed Mar 21 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.