# Run a google script from a node

**URL:** https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564
**Category:** General
**Created:** [2 April 2021 16:19 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564 "2021-04-02T16:19:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kusi](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kusi](https://discourse.nodered.org/u/kusi)
#### Post date: [2 April 2021 16:19 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/1 "2021-04-02T16:19:54Z")

</div>

How do I run a google script from a node?

The most obvioius way it to use the REST API via HTTP POST  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d015564d753eeb299a200f2b415664060bbb03ef.png)

Calling a google script involves a redirect (HTTP 302 moved temporarily). The redirect is not handled with the "http request" node. This is discussed on a [Github issue](https://github.com/node-red/node-red/issues/2017)

This works well via wget in regular bash on my Raspberry, but unfortunately the wget available in the nodred docker container results in another error (HTTP 405)

What other options do I have to invoke a google script?

- Am I doing something wrong to invoke the HTTP request node?
- Are there other options?

Thanks for any hint!

---

<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: [2 April 2021 16:50 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/2 "2021-04-02T16:50:50Z")

</div>

> [@kusi](#):
>
> Thanks for any hint!

If you are in a position to do so, maybe you could try out the workaround in the issue...

> Changing this line from
> 
> `opts.followRedirect = msg.followRedirects;`
> 
> to
> 
> `opts.followAllRedirects = msg.followRedirects;`
> 
> fixes it for me

---

<div class="post-metadata">

### Author: ![kusi](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kusi](https://discourse.nodered.org/u/kusi)
#### Post date: [2 April 2021 21:43 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/3 "2021-04-02T21:43:18Z")

</div>

You mean to change it in a function node? I've tried this

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be16e0d7657c10a130796e14ad38f5caa56657a9.png)

but it didn't work out

---

<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: [2 April 2021 21:57 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/4 "2021-04-02T21:57:40Z")

</div>

No, modify the js file as described in the issue.

---

<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: [2 April 2021 22:10 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/5 "2021-04-02T22:10:05Z")

</div>

> [@kusi](#):
>
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d015564d753eeb299a200f2b415664060bbb03ef.png)

Actually, what node is this? It doesn't look like the standard http request node.

What version of node-red and nodejs are you running?

---

<div class="post-metadata">

### Author: ![kusi](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kusi](https://discourse.nodered.org/u/kusi)
#### Post date: [2 April 2021 22:58 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/6 "2021-04-02T22:58:16Z")

</div>

First screenshot was with node-red-contrib-https  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d668b578e6a14bbf60087e153229581627454052.png)

But I was also trying with the standard http node, with the suggested modification, without success  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6bde3e13ff0dc683e305110149456e27f2175233.png)

I guess I finally found the file (the link to the corresponding github repo is not valid anymore) and applied the change to 21-httprequest.js. I restarted the container, redeployed the flows, but still HTTP302

I run node-red in a docker container. Might this be an issue? My versions  
NodeRed 1.2.9

---

<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: [1 June 2021 22:59 UTC](https://discourse.nodered.org/t/run-a-google-script-from-a-node/43564/7 "2021-06-01T22:59:09Z")

</div>

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