Invoke-WebRequest,带参数的GET抛出异常

s p*_*s p 6 c# powershell

需要从PowerShell脚本调用以下URL:

$webAPIUrl =  "http://hostName:portNumber/test/schedule-process/22/true"
Run Code Online (Sandbox Code Playgroud)

调用异常时抛出"发生错误".
PowerShell脚本:

Invoke-WebRequest -Uri $webAPIUrl -Method get -UseBasicParsing
Run Code Online (Sandbox Code Playgroud)

使用Postman检查此URL时抛出了相同的异常.

C#API代码:

  public class ScheduleController : ApiController  
  {  
      [HttpGet]  
      public void SchedulingProcess(int scheduleId, bool isScheduleStart)  
      {  

      }  
  }  
Run Code Online (Sandbox Code Playgroud)

路线配置代码:

config.Routes.MapHttpRoute("SchedulingProcess","test/schedule-process/{scheduleId}/{isScheduleStart}",new { controller = "Schedule", action = "SchedulingProcess" });  
Run Code Online (Sandbox Code Playgroud)

从C#调用时工作正常:

string webAPIUrl = "http://hostName:portNumber/test/schedule-process/22/true";
new WebClient().OpenReadAsync(new Uri(webAPIUrl));
Run Code Online (Sandbox Code Playgroud)

请帮我从PowerShell脚本调用此URL.

hds*_*uza -1

网址无效。“http://主机名:端口号/test/schedule-process/22/true”。请使用有效的 URL。