0

The HTTP Trigger sample for PowerShell uses POST but I need to be able to use GET. The software I want to integrate with can only do GET.

The example begins with:

$requestBody = Get-Content $req -Raw | ConvertFrom-Json

I tried /api/MyFunction?code=stuffstuffstuff==&param1=asdf&param2=1234 expecting that $requestBody would be param1=asdf&param2=1234. Instead, it's just empty.

I looked at the JavaScript example and had no trouble doing this. On a GET request the querystring parameters are available in req.query vs POST which is req.body.

Has this possibly not been implemented for PowerShell yet?

0

1 Answer 1

3

Use $req_query_param1 and $req_query_param2 variables

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"
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow. Don't I feel a bit silly. I had deleted those lines in the beginning once I got my function working the way I wanted it to. I think I'll put in a PR for the code sample to make it a little more obvious for people like me. haha

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.