Azure / Azure/azure-functions-powershell-worker

UrlEncoded POST is not parsed but GET query parameters are.

Open
#307 0 comments 0 reactions 2 assignees Claimed by @eamonoreilly View on GitHub
Dominant language
C#
Stars
215
Forks
61
Avg merge
21h 4m
Merged PRs (30d)
6

Description

Related behavior to: https://github.com/Azure/azure-functions-nodejs-worker/issues/146

# Reproduction
## GET Method (works as expected)
```powershell
iwr http://localhost:7071/api/TestMailflow -method 'GET' -body @{to='someone@somewhere.com'}
```
### $TriggerMetadata Query property has "to" as well as a new direct "to" property
```
[8/9/2019 7:29:00 PM] OUTPUT: TriggerMetadata
[8/9/2019 7:29:00 PM] OUTPUT: Query {to}
[8/9/2019 7:29:00 PM] OUTPUT: to someone@somewhere.com
```

## POST Method
```powershell
iwr http://localhost:7071/api/TestMailflow -method 'POST' -body @{to='someone@somewhere.com'}
```
### $TriggerMetadata doesn't have a query property. Expected behavior is same as GET
```
[8/9/2019 7:33:10 PM] OUTPUT: TriggerMetadata
[8/9/2019 7:33:10 PM] OUTPUT: Query {}
```

# Impact
As an example, if you have an Output Binding and you want to just bind it directly to {myparamname}, with GET it works fine, but with POST it never gets set as a metadata binding and therefore cannot be used in the output binding without having to parse the urlencoded POST and then pass it to Push-OutputBinding (assuming that can be done at all)

## Recommended Fix
If the content type is x-www-form-urlencoded it should be parsed just like query parameters

## Workarounds
1. Detect POST from $TriggerData.Method and parse $Request.rawbody directly.
1. Submit the POST as JSON (JSON will parse in a POST into HTTP metadata. Requires new client behavior

Javascript worker team decided to make this a "wontfix", however since the powershell worker is still in preview I would think as a powershell user that if you are using Invoke-Restmethod to call a powershell function, you would expect it to parse the -Body parameter regardless of the HTML method, rather than have to do the JSON workaround for a better usability case.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.