# HTTP Request node question

**URL:** <https://discourse.nodered.org/t/http-request-node-question/75357>\
**Category:** General\
**Tags:** http-request\
**Created:** [17 February 2023 16:40 UTC](https://discourse.nodered.org/t/http-request-node-question/75357 "2023-02-17T16:40:26Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 February 2023 16:40 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/1 "2023-02-17T16:40:26Z")

</div>

I am using a Node Red _Alexa node_ that asks for me to renew my token from time to time by simply login in to 192.168.1.57:3456 (my Home Assistant IP).

I would think, usually a bad sign, that a simple HTTP request node would do this. But that is where my expertise ends.

This is what the node is asking for:

![open in browser](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/951c1567d114ccb5e468c5459bf5520d5d8f94c7.jpeg)

If I open 192.168.1.57:3456 in my browser, I am prompted for my Amazon password, then told that my token is renewed and to close the browser.

![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/4/e43e835f310217a7e77739be4ee4295bcab5d792.jpeg)

So, is HTTP request the correct node to accomplish this?  
Which method? Put, for example, returns a 405 error:

![put](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/258e5e011dc5c669f8d68b9cb48e95176be77ccd.jpeg)

Also, if I put the address into my browser again, I get a 404 error.

My goal is to open the address once every day to keep the token refreshed. A 404 error is inconsequential and to be ignored.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 February 2023 17:31 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/2 "2023-02-17T17:31:37Z")

</div>

No http request will not work, the ip:3456 is a temp proxy address opened by the alexa remote2 node to allow authorization.

I find it best to save the authorization to flow context, and reinitialise every 24hrs and use the saved cookie in flow context  
e.g.

```auto
[{"id":"48d034130f262ec8","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"86400","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"#:(file)::alexa","payloadType":"flow","x":190,"y":2060,"wires":[["f78696691771c3ee"]]},{"id":"3b6342b82af27c5f","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"#:(file)::alexa","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":2060,"wires":[[]]},{"id":"f78696691771c3ee","type":"alexa-remote-init","z":"b779de97.b1b46","name":"","account":"c8738129.d902c","option":"initialise","x":380,"y":2060,"wires":[["3b6342b82af27c5f"]]},{"id":"c8738129.d902c","type":"alexa-remote-account","name":"alexa remote 2","authMethod":"proxy","proxyOwnIp":"localhost","proxyPort":"3456","cookieFile":"","refreshInterval":"14","alexaServiceHost":"layla.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-GB","onKeywordInLanguage":"","userAgent":"","useWsMqtt":"on","autoInit":"off"}]

```

You then turn off auto int in the config node.

 ![chrome_screenshot_1676655014545](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a9d5ca3072426f9a5126f41667d20958ba44e3b7.png)  
You then log on using proxy, after done once the saved auth payload will do the auth update every 24 hrs. I haven't need to manually log in for over a year.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 February 2023 17:51 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/3 "2023-02-17T17:51:46Z")

</div>

Thanks. This makes sense, but where do I find the cookie data to save in the flow context?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 February 2023 18:12 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/4 "2023-02-17T18:12:10Z")

</div>

When you press the inject button, first time you will see a message "open ip:3456 on browser" under the initialise node. log in as before on that proxy page. the change node then saves the auth cookie return by the initialise node. next time you press inject or every 24hrs the saved auth is sent to the initialise node, and authorises you without having to use the browser proxy address.

Make sure the context is using file and not memory.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 February 2023 20:48 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/5 "2023-02-17T20:48:06Z")

</div>

Now it's making sense. Thanks for the assist.  
But, now I can't log in on the proxy page. (Probably unrelated).  
My browser takes me to an Amazon page. It's never done that before.

 ![alexa what](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/da81921be17a60d5ee9382fc0ed99935fec1c728.jpeg)

Also, my nodes are saying "Port 3456 is already in use where they formerly said to open IP:3456.

![port 3456 is already in use](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36ed6405d26f2887f218ee3154de5a78453dc410.jpeg)

Ant the Initialize Node is a bit different, also, saying to open localhost:3456 instead of the IP:3456.

![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6ecfa495e4535a635c431559f4b921c4fdcb0025.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 February 2023 21:02 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/6 "2023-02-17T21:02:59Z")

</div>

Never seen that login before, no idea there

The initialise node needs to be the only one using the config and the auto int needs to be off in that config.

ip or localhost depends if you are on same machine as node-red.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [18 February 2023 00:23 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/7 "2023-02-18T00:23:48Z")

</div>

Thanks- Making more progress here.  
I had some issues until I realized that you are in the UK. I changed my Service Host and it appears that everything is working.

Is there a way to verify it? Also, how can I make the flow save to file?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 February 2023 00:54 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/8 "2023-02-18T00:54:40Z")

</div>

Not sure what you mean by verify it.

If you mean a text file you can use file read and write nodes.  
If you mean file context storage, then you need to edit your settings file  
[https://nodered.org/docs/user-guide/context#context-stores](https://nodered.org/docs/user-guide/context#context-stores)

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [18 February 2023 01:14 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/9 "2023-02-18T01:14:58Z")

</div>

I did not know tht option existed- thanks.  
So it's as simple as adding:

```auto
contextStorage: {
   default: {
       module: "localfilesystem"
   }
}

```

to my settings.js file?

Now, where would the files be saved since I don't have a `/.node-red` folder?  
(My NodeRed is an addon in Home Assistant, but you probably already figured that out).

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 February 2023 01:18 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/10 "2023-02-18T01:18:30Z")

</div>

No idea I do not use HA. Maybe ask on the HA forum Node-red section.  
As to adding to settings file, there should be a section of the file already there, you probably just need to edit it or uncomment it. As always make a copy first.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2023 22:52 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/11 "2023-02-21T22:52:48Z")

</div>

@E1cid Thanks. I have it working as needed. Perhaps too well. Apparently every context is going to file because In just two days my context folder is 1.5MB.

```auto
sudo du -sh /root/config/node-red/context
 1.5M /root/config/node-red/context

```

This is what I put into my _settings.js_ file:

```auto
    // Save context data to the file-system
    // Context files are saved in /root/config/node-red/context
    // To see the disk used: sudo du -sh /root/config/node-red/context
    contextStorage: {
        default: {
        module: 'localfilesystem'
        }
   }

```

However, the context data that I need to survive a restart is only written once a day (an Amazon token). All other context variables are volatile and don't need to be saved.

I saw this in some of my searching:

```auto
contextStorage: {
  default: "file",
  memoryOnly: { module: 'memory' },
  file: { module: 'localfilesystem' }
},

```

So here's my latest question.  
I am guessing that this will take care of the defaults, but **how do I specify which context variable is saved in the filesystem?**

```auto
contextStorage: {
  default: "memoryOnly",
  memoryOnly: { module: 'memory' },
  file: { module: 'localfilesystem' }
},

```

Thanks again.

---

<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 February 2023 23:07 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/12 "2023-02-21T23:07:07Z")

</div>

> [@SteveMann](#):
>
> how do I specify which context variable is saved in the filesystem

In the change nodes & other nodes that permit, you will see a selector for which context store.

In function nodes, check the function signature auto completion help (assuming you are using a recent version of node-red & have Monaco editor selected) OR read the help : [Writing Functions : Node-RED](https://nodered.org/docs/user-guide/writing-functions#multiple-context-stores)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [21 February 2023 23:09 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/13 "2023-02-21T23:09:23Z")

</div>

In the change node you select the context in the rule.

 ![chrome_screenshot_1677020868871](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e07f8d4278c2bc0c7180ee905b9ff73d7e9ca0d9.png)

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [21 February 2023 23:15 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/14 "2023-02-21T23:15:22Z")

</div>

I appreciate that you didn't tell me to [RTFM](https://nodered.org/docs/user-guide/context), because it is mostly there.

I also stumbled onto a [YouTube video](https://www.youtube.com/watch?v=IFJpv67ziXo) that explains the subject very well.

Again, your patience is appreciated.

BTW, where are you? I am assuming somewhere in Europe because of the timing of your assistance responses. (Boston, USA here).

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [21 February 2023 23:31 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/15 "2023-02-21T23:31:36Z")

</div>

You seem to have had a search, so thought you may of just missed it.  
I'm in the UK,

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [22 February 2023 00:00 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/16 "2023-02-22T00:00:57Z")

</div>

We will be there for a few days this summer, but would like to come back and spend a month or two driving around the country.

---

<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:** [23 April 2023 00:01 UTC](https://discourse.nodered.org/t/http-request-node-question/75357/17 "2023-04-23T00:01:52Z")

</div>

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