Hi I need to post a request to aspx page within dos command line.. How can I do that ?
You can use either curl or wget command to send HTTP requests from UNIX or Linux operating system. Both commands allow you to send GET and POST requests, which means you can also call REST web services. I have a Java web application, which runs on Linux and exposes WebServices.
Curl is a popular command-line tool that allows you to send requests to the server, upload files, and submit web forms. Curl supports over 25+ protocols, including HTTP, HTTPS, SFTP, FTP, and has built-in support for web forms, SSL, user authentication, and HTTP cookies. Curl works on Linux, Windows, and Mac.
Create a .vbs file containing:
' Set your settings
strFileURL = "http://localhost/index.aspx"
strHDLocation = "stream.temp"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
' Delete the temp file
objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
Then execute using:
cscript.exe scriptname.vbs
All of these answers require installing a windows feature or other program. Powershell is installed by default and can be run from the command line
powershell -command "Invoke-WebRequest -Uri %url% -Method POST"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With