# How to add the right header to a http request node?

**URL:** https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021
**Category:** General
**Tags:** http-request, function-node
**Created:** [21 January 2022 16:06 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021 "2022-01-21T16:06:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Paganosterix](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@Paganosterix](https://discourse.nodered.org/u/Paganosterix)
#### Post date: [21 January 2022 16:06 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/1 "2022-01-21T16:06:53Z")

</div>

Hi,  
i don't understand how to add a header for an http request node.  
I want to use a GET for the URL "[https://www.minecraft.net/en-us/download/server/bedrock](https://www.minecraft.net/en-us/download/server/bedrock)". But i only get a timeout error. The reason seems to be the missing header during the request.  
I tried several ideas to set the header with the function node, but without success. Any ideas how to get the http request node working with this URL?

Thx  
Pag.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [21 January 2022 16:10 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/2 "2022-01-21T16:10:54Z")

</div>

If you know which headers you need this cookbook entry may help  
[https://cookbook.nodered.org/http/set-request-header](https://cookbook.nodered.org/http/set-request-header)

---

<div class="post-metadata">

### Author: ![Paganosterix](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@Paganosterix](https://discourse.nodered.org/u/Paganosterix)
#### Post date: [21 January 2022 16:40 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/3 "2022-01-21T16:40:16Z")

</div>

That's maybe one of my problems. I can't identify what's needed.  
This tutorial i already tried without any success.

---

<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: [21 January 2022 17:11 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/4 "2022-01-21T17:11:47Z")

</div>

Open the link in your browser, open devtools (usually F12), select the network tab, refresh your page, look at the request details you will see all the headers used by your browser.

Follow the coup once again and add these headers.

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [24 January 2022 13:25 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/5 "2022-01-24T13:25:14Z")

</div>

Hello .. did you get this resolved ?

I was playing around a bit with this and apparently you have to make two requests to the same url  
one to establish a connection to the server and get a cookie  
and with the second to pass that cookie along to get to the actual website

```auto
[{"id":"867b6b9672d87079","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1040,"wires":[["78f483f677659b18"]]},{"id":"507b096eaaa97cfa","type":"http request","z":"54efb553244c241f","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.minecraft.net/en-us/download/server/bedrock","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":490,"y":1040,"wires":[["765707680a2fef55","c5cac10dd8331c31"]]},{"id":"cc7827b303c08904","type":"debug","z":"54efb553244c241f","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":1040,"wires":[]},{"id":"78f483f677659b18","type":"function","z":"54efb553244c241f","name":"initial req","func":"msg.headers = {\n \"User-Agent\": \"PostmanRuntime/7.29.0\",\n \"Accept\": \"*/*\",\n \"Cache-Control\": \"no-cache\",\n \"Host\": \"www.minecraft.net\",\n \"Accept-Encoding\": \"gzip, deflate, br\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1040,"wires":[["507b096eaaa97cfa"]]},{"id":"765707680a2fef55","type":"function","z":"54efb553244c241f","name":"set Cookies","func":"msg.cookies = msg.responseCookies;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":1040,"wires":[["0f2bac5c29abdda5"]]},{"id":"0f2bac5c29abdda5","type":"http request","z":"54efb553244c241f","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.minecraft.net/en-us/download/server/bedrock","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":850,"y":1040,"wires":[["cc7827b303c08904"]]},{"id":"c5cac10dd8331c31","type":"debug","z":"54efb553244c241f","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":980,"wires":[]}]

```

dont know what that gibberish reply is in the payload of the first request

---

<div class="post-metadata">

### Author: ![Paganosterix](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@Paganosterix](https://discourse.nodered.org/u/Paganosterix)
#### Post date: [29 January 2022 13:56 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/6 "2022-01-29T13:56:08Z")

</div>

Sorry for my late response. That was a great help for my task. Thank you so much!

---

<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: [12 February 2022 13:56 UTC](https://discourse.nodered.org/t/how-to-add-the-right-header-to-a-http-request-node/57021/7 "2022-02-12T13:56:35Z")

</div>

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