You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, for an httptrigger function, null or empty values cannot be passed in the query string.
Repro: create a default http trigger function. The name of my function is ProcessData. In the run.ps1 file, define the following:
usingnamespaceSystem.Net# Input bindings are passed in via param block.param($Request,$TriggerMetadata)
Write-Host"PowerShell HTTP trigger function processed a request."# Update req_query with the query of the request$req_query=@{
name=$Request.query.namecost=$Request.query.cost
}
Write-Host$req_query# Associate values to output bindings by calling 'Push-OutputBinding'.Push-OutputBinding-Name response -Value ([HttpResponseContext]@{
StatusCode= [HttpStatusCode]::OK
Body=$req_query
})
The $uri below has a null value for name in the query string.
$uri='http://localhost:2056/api/ProcessData?name&cost=10'$result= irm -Uri $request-Method Post
However, the $Request.query.name property will not be available. By default, the Functions Host, drops any values that are null or empty in the query string. To support this functionality, we need to add the UseNullableValueDictionaryForHttp capability to the PowerShell language worker, so the Functions Host sets the values in the query string as a nullable type. After enabling the capability, we need to add code to the PowerShell language worker to parse the rpcHttp.NullableQuery and headers. This will be a breaking change, so we will not fix this until we enable support for PowerShell 7.4.
As a workaround, the user can use the $TriggerMetadata[$keyName] to retrieve the query property. This is what the function will look like with the workaround which works as expected.
usingnamespaceSystem.Net# Input bindings are passed in via param block.param($Request,$TriggerMetadata)
Write-Host"PowerShell HTTP trigger function processed a request."# Update req_query with the query of the request$req_query=@{
name=$TriggerMetadata["name"]
cost=$TriggerMetadata["cost"]
}
Write-Host$req_query# Associate values to output bindings by calling 'Push-OutputBinding'.Push-OutputBinding-Name response -Value ([HttpResponseContext]@{
StatusCode= [HttpStatusCode]::OK
Body=$req_query
})
The text was updated successfully, but these errors were encountered:
Francisco-Gamino
changed the title
[Httptrigger] Add support to nullable types in query string
[Httptrigger] Add support for nullable types in query string
Nov 20, 2022
Currently, for an httptrigger function, null or empty values cannot be passed in the query string.
Repro: create a default http trigger function. The name of my function is
ProcessData
. In the run.ps1 file, define the following:The
$uri
below has a null value forname
in the query string.However, the
$Request.query.name
property will not be available. By default, the Functions Host, drops any values that are null or empty in the query string. To support this functionality, we need to add theUseNullableValueDictionaryForHttp
capability to the PowerShell language worker, so the Functions Host sets the values in the query string as a nullable type. After enabling the capability, we need to add code to the PowerShell language worker to parse the rpcHttp.NullableQuery and headers. This will be a breaking change, so we will not fix this until we enable support forPowerShell 7.4
.As a workaround, the user can use the
$TriggerMetadata[$keyName]
to retrieve the query property. This is what the function will look like with the workaround which works as expected.The text was updated successfully, but these errors were encountered: