Investigative information
Please provide the following:
N/A - this issue is reproducible locally.
Repro steps
Provide the steps required to reproduce the problem:
Run the following Typescript function:
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
context.res = {
body:context.bindingData
}
}
With the following function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"route": "periods/{id}",
"methods": [
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "../dist/TestFunc/index.js"
}
Run func start
Hit the URL with 0 as the parameter:
curl <function-url>/api/periods/0
Output is:
{
"invocationId": <hash>,
"id": {
"string": "0",
"data": "string"
},
....
}
Hit the URL with 1 as the parameter
curl <function-url>/api/periods/1
Output is:
{
"invocationId": <hash>,
"id": 1
...
}
Expected behavior
Format should be the same no matter what value is passed in.
Actual behavior
Format is integer literal for non-zero values (id: 1) and an object ({ ... }) for zero values.
Known workarounds
You can detect and respond in code, but that is ugly.
Related information
Provide any related information
- Programming language used: Typescript
- Links to source: Above
- Bindings used: Above
Source
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
context.res = {
body:context.bindingData
}
}
Investigative information
Please provide the following:
N/A - this issue is reproducible locally.
Repro steps
Provide the steps required to reproduce the problem:
Run the following Typescript function:
With the following
function.json{ "bindings": [ { "authLevel": "anonymous", "type": "httpTrigger", "direction": "in", "name": "req", "route": "periods/{id}", "methods": [ "get" ] }, { "type": "http", "direction": "out", "name": "res" } ], "scriptFile": "../dist/TestFunc/index.js" }Run
func startHit the URL with 0 as the parameter:
curl <function-url>/api/periods/0Output is:
{ "invocationId": <hash>, "id": { "string": "0", "data": "string" }, .... }Hit the URL with 1 as the parameter
curl <function-url>/api/periods/1Output is:
{ "invocationId": <hash>, "id": 1 ... }Expected behavior
Format should be the same no matter what value is passed in.
Actual behavior
Format is integer literal for non-zero values (
id: 1) and an object ({ ... }) for zero values.Known workarounds
You can detect and respond in code, but that is ugly.
Related information
Provide any related information
Source