This post is about an app I developed for this purpose. In this post, I’ll demonstrate how to create POST request on the Windows command line, or incorporate with a Batch file.
Generally, everything that can be done via the command line is useful for automation, tasks (Windows Task Scheduler) and easy integration between systems (usually old systems, even though can create an HTTP request usually can execute a batch file).
Allowing automation of HTTP request is what motivated me to create this tool. I would like to thank anyone that is considering supporting me and buying my software. It means a lot.
Download a file from the Internet using the command line
You can use cmdlinepost.exe tool to download files from the internet and save them where ever you wish.
1 |
cmdlinepost.exe /url http://www.example.com/somefile.exe /o myfile.demo |
Parameters explanation:
/url – specify the URL of the file you want to download. Both HTTP and https protocols are supported.
/o – specify the path for the downloaded file. If not a full path is provided, it will be saved where cmdlinepost.exe is located. If you want the file name to be determined automatically write “default” as the parameter value.
Create a raw HTTP request from the command line
cmdlinepost.exe supports raw HTTP requests. This can be done by sending a text file as a parameter for the program.
1 |
cmdlinepost.exe /i script.txt /https /o default |
Parameters explanation:
/i – specify the path for the script file that contains the raw HTTP request text.
/https – use this parameter to indicate that the request should be done via secure HTTP. Https is not a part of the raw HTTP request and thus should be noted separately.
An example of a raw HTTP request:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
POST /invoices HTTP/1.1 Host: example.com Connection: keep-alive Content-Length: 5752 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 Cookie: ASP.NET_SessionId=jxarihefmpb3i0cntmxhwqpk AlexaToolbar-ALX_NS_PH: AlexaToolbar/alx-4.0.3 __EVENTTARGET=ctl00%24ContentPlaceHolder1%24lbtnExcel&_.... |
Of course that every header is supported like basic authentication, Cookies, etc. All methods are supported as well.
Using a script file like this is the most flexible way to work with cmdlinepost.exe
Post data to an address from the command line
You can use cmdlinepost.exe to create POST requests quickly from the command line:
1 |
cmdlinepost.exe /url https://www.example.com/service /method post /payload "form data here" |
Parameters explanation:
/method – select which method should cmdpostline.exe use for the request. default is GET.
/payload – use this parameter to specify the payload of the request
More features:
- Initiate SOAP methods on a web service.
- POST / PATCH / DELETE (and more) requests over RESTful API
- Specify file encoding.
- Time requests
- Use basic authentication
Features to be added soon:
Support for client certificates.
I’ll update this post with a lot more that can be done with cmdlinepost.exe (and perhaps think of a better name for it 🙂 )