[英]How do I use GET with PowerShell in Azure Functions?
The HTTP Trigger sample for PowerShell uses POST but I need to be able to use GET. PowerShell的HTTP触发器示例使用POST,但我需要能够使用GET。 The software I want to integrate with can only do GET.
我要集成的软件只能执行GET。
The example begins with: 该示例开始于:
$requestBody = Get-Content $req -Raw | ConvertFrom-Json
I tried /api/MyFunction?code=stuffstuffstuff==¶m1=asdf¶m2=1234
expecting that $requestBody
would be param1=asdf¶m2=1234
. 我尝试了
/api/MyFunction?code=stuffstuffstuff==¶m1=asdf¶m2=1234
期望$requestBody
是param1=asdf¶m2=1234
。 Instead, it's just empty. 相反,它只是空的。
I looked at the JavaScript example and had no trouble doing this. 我看了看JavaScript示例,这样做很容易。 On a GET request the querystring parameters are available in
req.query
vs POST which is req.body
. 在GET请求中,querystring参数在
req.query
vs POST(即req.body
。
Has this possibly not been implemented for PowerShell yet? 这可能尚未为PowerShell实施吗?
Use $req_query_param1
and $req_query_param2
variables 使用
$req_query_param1
和$req_query_param2
变量
Invoke URL: 调用网址:
https://<your funcname>.azurewebsites.net/api/HttpTriggerPowerShell1?code=<your code>&test1=test2
Function code: 功能码:
$requestBody = Get-Content $req -Raw | ConvertFrom-Json
if ($req_query_test1)
{
$name = $req_query_test1
}
Out-File -Encoding Ascii -FilePath $res -inputObject "Hello $name"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.