# TypeError: Invalid character in header content \["getKeyByValue"\]

**URL:** <https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829>\
**Category:** General\
**Created:** [5 April 2022 13:09 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829 "2022-04-05T13:09:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Radstake](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radstake/32/59604_2.png) [@Radstake](https://discourse.nodered.org/u/Radstake)\
**Post date:** [5 April 2022 13:09 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/1 "2022-04-05T13:09:00Z")

</div>

Hi,

When I'm setting a header in the http out, I get this fatal error.

TypeError: Invalid character in header content ["getKeyByValue"]

That wasnt there before, maybe it started after a nodejs upgrade.

Some help in the right direction would be helpful, thx!

- Provide version numbers

> - node-red: 2.2.2
> - nodejs: v16.14.1

- You operating system (where node-red is running):

> PRETTY\_NAME="Raspbian GNU/Linux 10 (buster)"  
> NAME="Raspbian GNU/Linux"  
> VERSION\_ID="10"  
> VERSION="10 (buster)"  
> VERSION\_CODENAME=buster  
> ID=raspbian  
> ID\_LIKE=debian

- Show us where you see this?  
 ![Schermafbeelding 2022-04-05 om 15.40.10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/ac7aa0e01e68abdd72df24aae4da391eea64c1fd.png)

> See image above

- Explain what you are doing to cause it (calling endpoint? from postman? from webpage?)

> having a http in (get) execute some code / webrequested or other nodes (I have the same problem on multiple flows), create a json object and send it out via http out

- Grab a copy of the node-red log (it should include a stack trace to help us identify the issue)

> will have a look later today

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 April 2022 13:22 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/2 "2022-04-05T13:22:39Z")

</div>

Hi, it is not obvious where or how this error presents.

Could you please ...

- Provide version numbers
  - node-red
  - nodejs

- You operating system (where node-red is running)
- Show us where you see this?
- Explain what you are doing to cause it (calling endpoint? from postman? from webpage?)
- Grab a copy of the node-red log (it should include a stack trace to help us identify the issue)

> [@Radstake](#):
>
> That wasnt there before, maybe it started after a nodejs upgrad

How did you upgrade nodejs? Did you use official node-red update script?  
Did you also update node-red at the same time? If so, what was the previous version?

---

<div class="post-metadata">

**Author:** ![Radstake](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radstake/32/59604_2.png) [@Radstake](https://discourse.nodered.org/u/Radstake)\
**Post date:** [5 April 2022 13:45 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/3 "2022-04-05T13:45:00Z")

</div>

Hi!

Thanks for you reaction. I updated the post with the requested data.  
In addition: Im not sure if its liked. But I updated node js a week or so ago, i think it started then. today a node red upgrade via official script, error still there.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 April 2022 13:58 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/4 "2022-04-05T13:58:41Z")

</div>

Hi, thanks for providing the info.

You said in your original post that this was a fatal error. Is node red actually crashing?

Can you show us your flow, especially the area where the error occurs? Also add a debug node (set to to show complete message) before the HTTP node where this error occurs so that we can see data that goes into the node.

---

<div class="post-metadata">

**Author:** ![Radstake](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radstake/32/59604_2.png) [@Radstake](https://discourse.nodered.org/u/Radstake)\
**Post date:** [5 April 2022 16:04 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/5 "2022-04-05T16:04:19Z")

</div>

Hi this is a test flow that has the same error

```auto
[
    {
        "id": "4c5ad8c7caa80822",
        "type": "tab",
        "label": "Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b6787bb51bdf5eb4",
        "type": "http in",
        "z": "4c5ad8c7caa80822",
        "name": "Test Endpoint",
        "url": "/test/:parameter",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 170,
        "y": 100,
        "wires": [
            [
                "492f71e9ef5cfb9b",
                "2f2132f8d66f9210"
            ]
        ]
    },
    {
        "id": "6f8c6e875075b463",
        "type": "http response",
        "z": "4c5ad8c7caa80822",
        "name": "",
        "statusCode": "",
        "headers": {
            "content-type": "application/json"
        },
        "x": 670,
        "y": 100,
        "wires": []
    },
    {
        "id": "492f71e9ef5cfb9b",
        "type": "function",
        "z": "4c5ad8c7caa80822",
        "name": "Response definition",
        "func": " msg.payload = {\n result: \"ok\",\n response: \"request was received\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 100,
        "wires": [
            [
                "6f8c6e875075b463"
            ]
        ]
    },
    {
        "id": "2f2132f8d66f9210",
        "type": "debug",
        "z": "4c5ad8c7caa80822",
        "name": "Do something",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 180,
        "wires": []
    }
]

```

Nod red is still running but the flow doesnt seem to but executed

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 April 2022 17:28 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/6 "2022-04-05T17:28:34Z")

</div>

Hi, so there is nothing in that flow I can use to determine the issue.

It appears the error message you are seeing is NOT from a node in that flow you have posted .

If you want further help, please answer / respond to the below...

- Which node is generating this error ( the one in your screenshot with ID ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/147dcc4eea61cd7601444d3725c65114b075784e.png) )

- What is calling the endpoint `Test Endpoint`?

---

<div class="post-metadata">

**Author:** ![Radstake](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radstake/32/59604_2.png) [@Radstake](https://discourse.nodered.org/u/Radstake)\
**Post date:** [6 April 2022 07:38 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/7 "2022-04-06T07:38:07Z")

</div>

- Which node is generating this error, \* you can use CTRL+F to find this node or click the ID in the debug message

> The HTTP out is causing the error

 ![Schermafbeelding 2022-04-06 om 09.33.06](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/4/247735fc15324b47cf15e2604daa82387ce89762.png)

- What is calling the endpoint `Test Endpoint` ?

> M2M, but in this test a browser, curl below

- can you provide a CURL that causes this issue?

Curl is getting no response and times out

 ![Schermafbeelding 2022-04-06 om 09.35.14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0f94c2504d5de69f955e897db569979fcc550d1b.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 April 2022 09:26 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/8 "2022-04-06T09:26:43Z")

</div>

Ok, as I said before, your demo flow works for me (which is not surprising) and that I think you did not post the actual flow that is causing this problem since the node ID in your demo flow is different to the ID shown in the debug message.

Lets try something else.

### Add a debug node set to show complete message

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9a727a20b8b119f11e3fa43633fb047b378f4a61.png)

### copy the value from debug message using the copy value button

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/344c5e3d612e189f6a224190b0976a53f559d59c.png)

### paste info a code block reply

`````  
`paste copied value here`  
`````

---

<div class="post-metadata">

**Author:** ![Radstake](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radstake/32/59604_2.png) [@Radstake](https://discourse.nodered.org/u/Radstake)\
**Post date:** [6 April 2022 10:01 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/9 "2022-04-06T10:01:53Z")

</div>

Hi,

it is the flow!, I created a new one thats why the id was different. result of your question:

infoblock:

```auto
{"_msgid":"ba5ea9bf488765f0","payload":{"result":"ok","response":"request was received"},"req":{"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":null,"ended":true,"endEmitted":false,"reading":false,"constructed":true,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":true,"dataEmitted":false,"decoder":null,"encoding":null},"_events":{},"_eventsCount":1,"socket":"[internal]","httpVersionMajor":1,"httpVersionMinor":1,"httpVersion":"1.1","complete":true,"rawHeaders":["Host","localhub.homecontrol.erichradstake.nl","User-Agent","curl/7.79.1","Accept","*/*","X-Forwarded-For","82.217.201.115","X-Forwarded-Host","localhub.homecontrol.erichradstake.nl","X-Forwarded-Server","localhub.homecontrol.erichradstake.nl","Connection","Keep-Alive"],"rawTrailers":[],"aborted":false,"upgrade":false,"url":"/test/testparameterparameter","method":"GET","statusCode":null,"statusMessage":null,"client":"[internal]","_consuming":false,"_dumped":false,"baseUrl":"","originalUrl":"/test/testparameterparameter","_parsedUrl":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":null,"query":null,"pathname":"/test/testparameterparameter","path":"/test/testparameterparameter","href":"/test/testparameterparameter","_raw":"/test/testparameterparameter"},"params":{"parameter":"testparameterparameter"},"query":{},"res":"[internal]","route":{"path":"/test/:parameter","stack":[{"name":"cookieParser","keys":[],"regexp":{" __enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"httpMiddleware","keys":[],"regexp":{" __enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"corsHandler","keys":[],"regexp":{" __enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"metricsHandler","keys":[],"regexp":{" __enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"<anonymous>","keys":[],"regexp":{" __enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"<anonymous>","keys":[],"regexp":{" __enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"}],"methods":{"get":true}},"cookies":{},"signedCookies":{}},"res":{}}

```

These are all the messages:

![Schermafbeelding 2022-04-06 om 12.00.30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2d8e7f95fe2d8a06a31387c2c298fb566f3ddd5d.png)

- The first is from the do something block
- The second fron the HTTP-OUT
- The third one, pastes above from the debug response definiton

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 April 2022 12:07 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/10 "2022-04-06T12:07:51Z")

</div>

I see nothing in that debug capture that would "upset" the `http-response` node.

In the raw headers, I see the request was made by curl (`curl/7.79.1`) - can you share the curl command that was used?

Also, for test purposes, can you try making the request from within your node-red like i have done...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/6050caa8353de9207caa11ce3086756eaeec2294.png)

```auto
[{"id":"b6787bb51bdf5eb4","type":"http in","z":"4c5ad8c7caa80822","name":"Test Endpoint","url":"/test/:parameter","method":"get","upload":false,"swaggerDoc":"","x":1730,"y":100,"wires":[["492f71e9ef5cfb9b","4e089c0a7ddc8dcc"]]},{"id":"6f8c6e875075b463","type":"http response","z":"4c5ad8c7caa80822","name":"","statusCode":"","headers":{"content-type":"application/json"},"x":2210,"y":100,"wires":[]},{"id":"492f71e9ef5cfb9b","type":"function","z":"4c5ad8c7caa80822","name":"Response definition","func":"\n msg.payload = {\n result: \"ok\",\n response: \"request was received\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2000,"y":100,"wires":[["6f8c6e875075b463","2402c1c647d720b0"]]},{"id":"cf4a6bf0d5f4ca66","type":"inject","z":"4c5ad8c7caa80822","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1760,"y":260,"wires":[["e0d7bbc72bc581c9"]]},{"id":"e0d7bbc72bc581c9","type":"http request","z":"4c5ad8c7caa80822","name":"REQ - http://localhost:1881/test/123","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://localhost:1881/test/123","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":1980,"y":260,"wires":[["f25c75e4a2d21b88"]]},{"id":"2402c1c647d720b0","type":"debug","z":"4c5ad8c7caa80822","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2180,"y":160,"wires":[]},{"id":"4e089c0a7ddc8dcc","type":"debug","z":"4c5ad8c7caa80822","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1820,"y":160,"wires":[]},{"id":"f25c75e4a2d21b88","type":"debug","z":"4c5ad8c7caa80822","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2200,"y":260,"wires":[]}]

```

#### NOTE: you will need to change the URL in the 👆 `http-request` node to suit your node-red.

---

<div class="post-metadata">

**Author:** ![Radstake](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radstake/32/59604_2.png) [@Radstake](https://discourse.nodered.org/u/Radstake)\
**Post date:** [6 April 2022 13:01 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/11 "2022-04-06T13:01:54Z")

</div>

Hi, yeah sorry for this strange case.  
Calling it internally with you flow results in the same error:  
 ![Schermafbeelding 2022-04-06 om 15.02.29](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4f82550ecb39fd71c3fd617251c4bb4d1815c26.png)

Keep stuck on requesting and therefor no debug 3 result

Curl command was:

> curl [http://192.168.178.50:1880/test/123](http://192.168.178.50:1880/test/123)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 June 2022 13:02 UTC](https://discourse.nodered.org/t/typeerror-invalid-character-in-header-content-getkeybyvalue/60829/12 "2022-06-05T13:02:49Z")

</div>

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