Question:
Need to invoke the following url from PowerShell script:
1 2 |
$webAPIUrl = "http://hostName:portNumber/test/schedule-process/22/true" |
While invoking exception thrown as “An error has occurred.”
PowerShell script:
1 2 |
Invoke-WebRequest -Uri $webAPIUrl -Method get -UseBasicParsing |
Same exception was thrown while checking this url with Postman.
C# API code:
1 2 3 4 5 6 7 8 9 |
public class ScheduleController : ApiController { [HttpGet] public void SchedulingProcess(int scheduleId, bool isScheduleStart) { } } |
Route configuration code:
1 2 |
config.Routes.MapHttpRoute("SchedulingProcess","test/schedule-process/{scheduleId}/{isScheduleStart}",new { controller = "Schedule", action = "SchedulingProcess" }); |
Working fine while calling from C#:
1 2 3 |
string webAPIUrl = "http://hostName:portNumber/test/schedule-process/22/true"; new WebClient().OpenReadAsync(new Uri(webAPIUrl)); |
Please help me to invoke this url from PowerShell script.
Answer:
The Url is invalid. “http://hostName:portNumber/test/schedule-process/22/true”. Please use a valid URL.