Read multiple parameters from HTTP In node

Hello,

In a terminal I run the following command:

curl -X GET http://localhost:1880/zonex/?x=3&y=4&radius=5

An HttpIn node is triggered in my flow. It is connected to function node which must get the request parameters and put them in the msg.payload.
Then a debug node should print :

{"x":"3", "y":"4","radius":"5"}

The result I get is x=3 and y and radius are undefined.

{"x":"3", y=undefined, radius = undefined}

Can you help me please ? don't hesitate to ask me to rephrase or complete my post.

Here is the flow's code:

[
    {
        "id": "fd3c017bbed97322",
        "type": "tab",
        "label": "Turbopi",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "http_in",
        "type": "http in",
        "z": "fd3c017bbed97322",
        "name": "",
        "url": "/zonex/",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 310,
        "y": 500,
        "wires": [
            [
                "function_node",
                "045e338e2dafe6ad"
            ]
        ]
    },
    {
        "id": "function_node",
        "type": "function",
        "z": "fd3c017bbed97322",
        "name": "Extract Parameters",
        "func": "// Extract query parameters\nvar x = msg.req.query.x;\nvar y = msg.req.query.y;\nvar radius = msg.req.query.radius;\n\n// Create a new message payload\nmsg.payload = {\n    x: x,\n    y: y,\n    radius: radius\n};\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 570,
        "y": 500,
        "wires": [
            [
                "debug_node"
            ]
        ]
    },
    {
        "id": "debug_node",
        "type": "debug",
        "z": "fd3c017bbed97322",
        "name": "Print Parameters",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 840,
        "y": 500,
        "wires": []
    },
    {
        "id": "045e338e2dafe6ad",
        "type": "http response",
        "z": "fd3c017bbed97322",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 750,
        "y": 400,
        "wires": []
    }
]

Without the original msg it's hard to say what you mean by "first parameter"

Try using
curl -X GET 'http://localhost:1880/zone?x=3&y=4&radius=5'

p.s.
A http in node must be paired with a http response node, your flow seems to be missing a http response node.
From the http in node help text

Note: this node does not send any response to the request. The flow must include an HTTP Response node to complete the request.

Also your flow json is corrupt as you have not followed forum guide lines when posting code.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

It works ! Thank you for your answer and comments.

The trick are the quotes:

OK
curl -X GET 'http://localhost:1880/zone?x=3&y=4&radius=5'
KO
curl -X GET http://localhost:1880/zone?x=3&y=4&radius=5

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.