需要从PowerShell脚本调用以下URL:
$webAPIUrl = "http://hostName:portNumber/test/schedule-process/22/true"
调用异常时抛出“发生错误。”
PowerShell脚本:
Invoke-WebRequest -Uri $webAPIUrl -Method get -UseBasicParsing
使用Postman检查此URL时抛出了相同的异常。
C#API代码:
public class ScheduleController : ApiController
{
[HttpGet]
public void SchedulingProcess(int scheduleId, bool isScheduleStart)
{
}
}
路线配置代码:
config.Routes.MapHttpRoute("SchedulingProcess","test/schedule-process/{scheduleId}/{isScheduleStart}",new { controller = "Schedule", action = "SchedulingProcess" });
从C#调用时工作正常:
string webAPIUrl = "http://hostName:portNumber/test/schedule-process/22/true";
new WebClient().OpenReadAsync(new Uri(webAPIUrl));
请帮我从PowerShell脚本调用此URL。
答案 0 :(得分:-1)
网址无效。 “http://hostName:portNumber/test/schedule-process/22/true”。请使用有效的网址。