How To Create a Basic Task To Invoke Your Web API In Windows

Mert Ilis
1 min readApr 6, 2016

--

Sometimes I need a basic task scheduler to invoke some operations served by my web api. I use a simple methodology for my recurrent tasks by using my RESTful API (ASP.Net WebApi application) and Windows’ Task Scheduler.

I follow these steps:

  • Create the poweshell script file (file type is ps1). Add invoke code like this:
Invoke-WebRequest -Headers @{"Authorization" = "Basic ???"} -ContentType application/json -Method POST -Uri https://???/task/sample
  • Create a basic scheduled task and to the program field call the script file like this:
powershell -command "C:\_Task\Sample_Hourly.ps1"

NOTE: Running powershell scripts require the change of execution policy. Run the command below in order to do that.

powershell.exe -command set-executionpolicy unrestricted

Hope it helps!

Originally published at https://www.weboideas.com on April 6, 2016.

--

--

Mert Ilis
Mert Ilis

Written by Mert Ilis

I’m a software development enthusiast who likes trying different web technologies and adding value to his team.

Responses (2)