skip to Main Content

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?

6

Answers


  1. You can try using wget for Windows.

    Login or Signup to reply.
  2. What are you allowed to install? Could you use wget for Windows for instance? Or write a .NET executable which does everything you need it to using WebClient or HttpWebRequest?

    Login or Signup to reply.
  3. Take a look at curl. It’s a cross-platform command-line tool for making web requests (similar to wget if you’ve used that before). You should be able to call that from your batch file.

    Login or Signup to reply.
  4. I would suggest either wget or curl. Win32 versions are available for both.

    Login or Signup to reply.
  5. The “curl” utiliity which is basically a command line wrapper for the wonderful libcurl library will handle almost any http request or response. Its freely available for free.

    Login or Signup to reply.
  6. Without external binaries – only the built-in windows capabilities -> https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/winhttpjs.bat

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

      call winhttpjs.bat "http://requestb.in/xxxxxx" -method POST -header hdrs.txt -reportfile reportfile2.txt
       
      call winhttpjs.bat "http://requestb.in/xxxxxx" -method GET -header hdrs.txt -reportfile reportfile3.txt -saveTo c:somezip.zip 
    
      call winhttpjs.bat "http://requestb.in/xxxxxx" -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))

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search