Http web request from batch file


I need to execute a http web request from Plesk's Task Scheduler (using shared hosting on Windows/ASP.NET; no Powershell, whatsoever). Thought about using a batch file for this.

Is there an easy way to do this?

Best Solution

Without external binaries - only the built-in windows capabilities ->

This is jscript/.bat hybrid and can be called like simple bat. Example usage (I've used for test purposes):

  call winhttpjs.bat "" -method POST -header hdrs.txt -reportfile reportfile2.txt
  call winhttpjs.bat "" -method GET -header hdrs.txt -reportfile reportfile3.txt -saveTo c:\ 

  call winhttpjs.bat "" -method POST -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"  -body-file some.json

Header files format should look like (if passed with -header command argument):

Header-1: Value-1
ExampleHeader: Value2

Does not support multi-part requests (though I'm planning to add such a feature (some day))