# Need help in http request node

**URL:** <https://discourse.nodered.org/t/need-help-in-http-request-node/68612>\
**Category:** General\
**Created:** [5 October 2022 22:49 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612 "2022-10-05T22:49:20Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![boo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/boo/32/67804_2.png) [@boo](https://discourse.nodered.org/u/boo)\
**Post date:** [6 October 2022 13:49 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/21 "2022-10-06T13:49:49Z")

</div>

@Steve-Mcl how to send msg.payload value from first node to last node?  
say i want to use the value of one msg.payload to last node to use as templete?  
what am i doing is send a magnetic torrent url from telegram and i have telegram node which detects and sends that data... cant i use that value like

```auto
var url = msg.payload.content
msg.payload = '-----------------------------6688794727912\r\n'+
    'Content-Disposition: form-data; name="urls"\r\n' +
    '\r\n' +
    url;

```

tried this but does not work..  
coz its not sending any value i guess as the flow passes to next node it kills the previous node values i guess  
what i want is to send telegram msg value to the funtion node as below and also trigger the 1st node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4c8c3472cb19fa0c358c81135646e77955ba0b24.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 October 2022 14:06 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/22 "2022-10-06T14:06:50Z")

</div>

> [@boo](#):
>
> how to send msg.payload value from first node to last node?

store it somewhere else in the `msg`

e.g. use a change node to copy (set) msg.originalPayload from msg.payload (deep copy)

OR in the 1st function...

```auto
msg.originalPayload = RED.util.cloneMessage(msg.payload)

```

then at the end you should see it in `msg.originalPayload`

---

<div class="post-metadata">

**Author:** ![boo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/boo/32/67804_2.png) [@boo](https://discourse.nodered.org/u/boo)\
**Post date:** [6 October 2022 14:24 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/23 "2022-10-06T14:24:11Z")

</div>

edit: works with change node deep copy

> [@Steve-Mcl](#):
>
> msg.originalPayload

did not work  
i added this in 1st funtion node before 1st http request node

```auto
msg.originalPayload = RED.util.cloneMessage(msg.payload.content);

```

then im reading it in other funtion node as

```auto
var y = msg.responseCookies.SID.value
var x = "SID="
var cookie = x + y
var link = msg.originalPayload
msg.url = "http://192.168.0.104:8080/api/v2/torrents/add";

msg.headers = {};
msg.method = "POST";
msg.headers["cookie"] = "cookie";
msg.headers["POST"] = "/api/v2/torrents/add HTTP/1.1";
msg.headers["Content-Type"] = "multipart/form-data; boundary=---------------------------6688794727912";
msg.headers["Host"] = "192.168.0.104:8080";
msg.cookie = cookie;
msg.payload = '-----------------------------6688794727912\r\n'+
    'Content-Disposition: form-data; name="urls"\r\n' +
    '\r\n' +
    link;
return msg;

```

but still it does not work  
payload fails  
and the first payload i saved is showing up in headers but cant read the value from it ..  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22ef4b19e8b90618f98910c392d79cae71c2b8e6.png)  
and this is the funtion node debug

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4d8c3a3ad6464e130987af39616ce546b52897b9.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 October 2022 14:39 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/24 "2022-10-06T14:39:17Z")

</div>

> [@boo](#):
>
> did not work  
> i added this in 1st funtion node before 1st http request node
> 
> ```auto
> msg.originalPayload = RED.util.cloneMessage(msg.payload.content);
> 
> ```

where does `msg.payload.content` come from? Which ever node generates that - put this code AFTER that.

Use debug nodes everywhere to understand what is happening in your flow.

Use `node.warn` inside your function nodes to understand what is going on inside the function

e.g. you show `msg.originalPayload ` as being `undefined` - was it EVER anything?

e.g. add a node.warn...

```auto
//
// ... other code ...
//
node.warn({ "msg.payload.content": msg.payload.content})
msg.originalPayload = RED.util.cloneMessage(msg.payload.content)
node.warn({ "msg.originalPayload": msg.originalPayload })
//
// ... other code ...
//

```

---

<div class="post-metadata">

**Author:** ![boo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/boo/32/67804_2.png) [@boo](https://discourse.nodered.org/u/boo)\
**Post date:** [6 October 2022 14:52 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/25 "2022-10-06T14:52:21Z")

</div>

it works now..when i add msg.originalPayload = RED.util.cloneMessage(msg.payload.content) at the top in fn node then it works

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2d48dee3d3e49294ea43a190e58ebb785b2debb9.png)  
if i do the same by adding at bottom it fails to send (whats where i made mistake but no sure why is it like that?)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/2607d84a42b2f739262279558a12f5402fe868c9.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 October 2022 14:58 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/26 "2022-10-06T14:58:24Z")

</div>

> [@boo](#):
>
> if i do the same by adding at bottom it fails to send (whats where i made mistake but no sure why is it like that?)

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

* * *

PS, please dont post pictures of code (use the code button and paste as text)

---

<div class="post-metadata">

**Author:** ![boo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/boo/32/67804_2.png) [@boo](https://discourse.nodered.org/u/boo)\
**Post date:** [6 October 2022 15:46 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/27 "2022-10-06T15:46:26Z")

</div>

~~hanks~~ [~~@~~~~ Steve ~~~~-~~~~ Mcl~~](https://discourse.nodered.org/u/steve-mcl)~~. ~~~~.~~~~. ~~~~sorry~~~~ for ~~~~posting~~~~ images ~~~~of~~~~ code ~~~~.~~  
~~one~~~~ help ~~~~.~~~~. ~~~~.~~~~ i ~~~~have~~~~ two ~~~~telegram~~~~ trigger ~~~~nodes~~~~ one ~~~~which~~~~ detects ~~~~commands~~~~ and ~~~~other~~~~ for ~~~~messages~~~~ and ~~~~contents~~~~. ~~~~.~~  ~~what~~~~ i ~~~~want~~~~ is ~~~~something~~~~ like ~~~~wait~~~~ untill ~~~~or~~~~ switch~~  
~~say~~~~ if ~~~~i~~~~ send ~~`/movie`~~ as ~~~~message~~~~ in ~~~~telegram~~~~ followed ~~~~by~~~~ message ~~~~as~~ `x` ~~then~~~~ it ~~~~should~~~~ start ~~~~one~~~~ flow~~  
~~same~~~~ if ~~~~i~~~~ send ~~`/series`~~ as ~~~~message~~~~ in ~~~~telegram~~~~ followed ~~~~by~~~~ message ~~~~as~~ `x` ~~then~~~~ it ~~~~should~~~~ start ~~~~other~~~~ flow ~~~~.~~  
~~Why~~~~ am ~~~~i~~~~ doing ~~~~this~~~~ is ~~~~:~~  ~~movies~~~~ or ~~~~series~~~~ both ~~~~the~~~~ torrent ~~~~magnet~~~~ link ~~~~starts~~~~ with ~~`magnet`~~ and ~~~~i~~~~ want ~~~~to~~~~ switch ~~~~this~~~~ because ~~~~i~~~~ want ~~~~to~~~~ add ~~~~torrent~~~~ with ~~~~different~~~~ categories ~~~~which~~~~ download ~~~~files~~~~ to ~~~~specific~~~~ filepath ~~~~which~~~~ then ~~~~runs~~~~ script ~~~~internally~~~~ to ~~~~scan~~~~ and ~~~~add~~~~ that ~~~~to~~~~ jelly ~~~~fin~~~~ server ~~~~under~~ `movies` ~~and~~ `series` ~~section~~

---

<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 October 2022 16:01 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/28 "2022-10-06T16:01:46Z")

</div>

This is a different subject.

Please mark it as solved.

For your new question: Please start a new thread with appropriate title. Include detail like "what you have" what you are trying to do" and a minimal flow using only standard nodes (e.g. an inject can "fake" the incoming telegram message" and a debug node can "fake" the outgoing telegram node)

---

<div class="post-metadata">

**Author:** ![boo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/boo/32/67804_2.png) [@boo](https://discourse.nodered.org/u/boo)\
**Post date:** [7 October 2022 15:01 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/29 "2022-10-07T15:01:15Z")

</div>

@Steve-Mcl  
how do i set this up in nodered? for json object and send as POST to [http://192.168.0.104:8080/api/v2/app/setPreferences](http://192.168.0.104:8080/api/v2/app/setPreferences)

```auto
json={"save_path":"C:/Users/Dayman/Downloads","queueing_enabled":false,"scan_dirs":{"C:/Games": 0,"D:/Downloads": 1}}

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a66c49f16f4893d9bfd78286d9145b53d706926d.png)  
should i create header with json?

---

<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:** [7 October 2022 15:06 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/30 "2022-10-07T15:06:06Z")

</div>

Same as before but set the payload before it goes to the HTTP node...

```auto
// ... other code
msg.payload = {
  "save_path":"C:/Users/Dayman/Downloads",
  "queueing_enabled":false,
  "scan_dirs":{
    "C:/Games": 0,
    "D:/Downloads": 1
  }
}
return msg;

```

---

<div class="post-metadata">

**Author:** ![boo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/boo/32/67804_2.png) [@boo](https://discourse.nodered.org/u/boo)\
**Post date:** [7 October 2022 16:46 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/31 "2022-10-07T16:46:34Z")

</div>

thanks one quick question i get a data with time like this  
`"added_on":1665160878`  
what i want is to compare time now with current time and check if its greater than `1665160878` what time format is this?  
if i could get current time in this format i can do the compare stuff

---

<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:** [7 October 2022 16:59 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/32 "2022-10-07T16:59:31Z")

</div>

Again. This is a different question & should be a different thread.

But to save you some time that number is a JavaScript epoch

From the net...

~~epoch time is Unix style in milliseconds since 01/01/1971, which means it returns a long number in milliseconds. It is epoch time or Unix timestamp. Javascript provides the Date object provides the date and time-related things~~

Didnt proof read that - @E1cid spotted a mistake. The number you are describing is a Unix Epoch which is number of s since 1970/01/01 00:00:00 UTC

JS works in MS so multiply by 1000 to get UTC

e.g: `1665160878 x 1000` = `16651608780000` == `2022-10-07T16:41:18.000Z`  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7d55dd2e8e2641d40d882b6e8f222c0bab816afd.png)

Search the forum for **epoch** or start a new thread.

---

<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:** [7 October 2022 17:24 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/33 "2022-10-07T17:24:41Z")

</div>

Looks like a unix timestamp in seconds.  
So all you need to do is multiple it by a 1000, then it can be compared with a Node-red JS timestamp, which is in milliseconds

[Edit] The unix Epoch date is 01-01-1970

---

<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:** [21 October 2022 17:25 UTC](https://discourse.nodered.org/t/need-help-in-http-request-node/68612/34 "2022-10-21T17:25:30Z")

</div>

Closed on 21 October 2022 17:25 UTC

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

[Previous page](https://discourse.nodered.org/t/need-help-in-http-request-node/68612.md?page=1)
