How to pass parameters between http in node and http request node

I have a http-in node and a http-request node, between them is a function node to handle parameters which post to http-in node, but the http-request node cannot receive the right parameters. How can I fixed it.

the flow code is

[
    {
        "id": "efbbf209f839382a",
        "type": "tab",
        "label": "execute",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "dda525132ed420c7",
        "type": "http in",
        "z": "efbbf209f839382a",
        "name": "",
        "url": "/device/function/AJ",
        "method": "post",
        "upload": false,
        "swaggerDoc": "",
        "x": 230,
        "y": 360,
        "wires": [
            [
                "05f4c5a8ca1ab45a"
            ]
        ]
    },
    {
        "id": "651e0e989fa4d9b5",
        "type": "http request",
        "z": "efbbf209f839382a",
        "name": "request a list",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "query",
        "url": "http://10.51.9.130:30768/hjmos-device/point/queryVirtualPoint",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 750,
        "y": 360,
        "wires": [
            [
                "6cd08b0d40cb3fc7",
                "940ddf000262ad49",
                "e8b5c3d557c5427a"
            ]
        ]
    },
    {
        "id": "d77dd7344222f345",
        "type": "switch",
        "z": "efbbf209f839382a",
        "name": "",
        "property": "payload.code",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1090,
        "y": 380,
        "wires": [
            [
                "94ead5091659165e"
            ],
            [
                "bd188e226ec2f1ed"
            ]
        ]
    },
    {
        "id": "bd10e0b7600a418d",
        "type": "function",
        "z": "efbbf209f839382a",
        "name": "set some flow vars",
        "func": "flow.set(\"ID-Token\", msg.headers['id-token'])\nflow.set(\"Authorization\", msg.headers['authorization'])\n// flow.set(\"devId\", msg.payload.devId)\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 280,
        "wires": [
            [
                "3d086c68e00395b4"
            ]
        ]
    },
    {
        "id": "3d086c68e00395b4",
        "type": "debug",
        "z": "efbbf209f839382a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 960,
        "y": 280,
        "wires": []
    },
    {
        "id": "6cd08b0d40cb3fc7",
        "type": "debug",
        "z": "efbbf209f839382a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1000,
        "y": 480,
        "wires": []
    },
    {
        "id": "bd188e226ec2f1ed",
        "type": "http response",
        "z": "efbbf209f839382a",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 1290,
        "y": 460,
        "wires": []
    },
    {
        "id": "94ead5091659165e",
        "type": "function",
        "z": "efbbf209f839382a",
        "name": "set params",
        "func": "const status = msg.payload.data == 0 ? 0 : 1\n\nmsg.payload = {\n    code: 0,\n\n    data: {\n        status\n    }\n    \n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1300,
        "y": 380,
        "wires": [
            [
                "e3d96df669171074"
            ]
        ]
    },
    {
        "id": "940ddf000262ad49",
        "type": "json",
        "z": "efbbf209f839382a",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 930,
        "y": 360,
        "wires": [
            [
                "d77dd7344222f345"
            ]
        ]
    },
    {
        "id": "8c2b31c72e0850c8",
        "type": "inject",
        "z": "efbbf209f839382a",
        "name": "测试",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "headers",
                "v": "{\"id-token\":\"86ba0e17-2510-4f45-be5c-18abe63f86a4\",\"authorization\":\"Basic MTAxOjEyMzQ1Ng==\"}",
                "vt": "json"
            },
            {
                "p": "post",
                "v": "Query_ComDetect_CCTV",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"groupCode\":\"Query_Run_Status_AJ\",\"params\":{\"lineId\":6,\"stationId\":79,\"gate\":1}}",
        "payloadType": "json",
        "x": 470,
        "y": 260,
        "wires": [
            [
                "651e0e989fa4d9b5"
            ]
        ]
    },
    {
        "id": "e8b5c3d557c5427a",
        "type": "debug",
        "z": "efbbf209f839382a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "req.body",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1040,
        "y": 560,
        "wires": []
    },
    {
        "id": "664ea8e55a8894aa",
        "type": "debug",
        "z": "efbbf209f839382a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 740,
        "y": 480,
        "wires": []
    },
    {
        "id": "e3d96df669171074",
        "type": "http response",
        "z": "efbbf209f839382a",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 1470,
        "y": 380,
        "wires": []
    },
    {
        "id": "05f4c5a8ca1ab45a",
        "type": "function",
        "z": "efbbf209f839382a",
        "name": "设置传参",
        "func": "msg.headers = msg.req.headers\n\nconst { lineId, stationId, devId } =  msg.payload\n\nmsg.payload = {\n    \"groupCode\": \"Query_Run_Status_AJ\",\n    \"params\": {\n        \"lineId\": lineId,\n        \"stationId\": stationId,\n        \"gate\": devId\n    }\n}\n\nmsg.ip = global.get('ip')\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 480,
        "y": 360,
        "wires": [
            [
                "651e0e989fa4d9b5",
                "bd10e0b7600a418d",
                "664ea8e55a8894aa"
            ]
        ]
    }
]

I believe your issue is setting the headers to msg.req.headers in the function. Try setting the headers to {} or only select the req header you require, not all of them.

Thanks for your reply. and yes, I haved set msg.headers = msg.req.headers in function node. :sweat_smile: I will modify it right now. Thanks a lot.

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