c# – 通过PowerShell将多个查询参数传递给WebService
发布时间:2020-12-15 23:28:14 所属栏目:百科 来源:网络整理
导读:我通过Power Shell调用webservice GET方法,如下所示: $result = Invoke-WebRequest -Uri https://localhost/MyApi/Foo/blahA/blahB?three=testingfour=2015-09-18T06:45:29.5199432Z 但是,这给了我以下错误: The ampersand () character is not allowed. T
我通过Power
Shell调用webservice GET方法,如下所示:
$result = Invoke-WebRequest -Uri https://localhost/MyApi/Foo/blahA/blahB?three=testing&four=2015-09-18T06:45:29.5199432Z 但是,这给了我以下错误:
如果重要的是我的WebAPI代码和路由(该方法有两个必需参数,3个可选): [HttpGet,ActionName("Foo")] public string Foo(string one,string two,string three = null,DateTime? four = null,int five = null) { //do stuff //return some string } ... routes.MapHttpRoute( name: "Foo",routeTemplate: "Foo/{one}/{two}",defaults: new { controller = "Testing",action = "Foo" } ); 解决方法
一些事情,你应该用双引号包装你的URI:
$result = Invoke-WebRequest -Uri "https://localhost/MyApi/Foo/blahA/blahB?three=testing&four=2015-09-18T06:45:29.5199432Z" 其次,你的网址一般看起来不对,试试吧 $result = Invoke-WebRequest -Uri "https://localhost/MyApi/Foo?one=blahA&two=blahB&three=testing&four=2015-09-18T06:45:29.5199432Z" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |