# Regarding to send a message from Node red to Niagara 4 framework

**URL:** <https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603>\
**Category:** General\
**Created:** [18 February 2022 14:33 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603 "2022-02-18T14:33:15Z")\
**Posts on this page:** 13\
**Page:** 2

<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 2022 14:09 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/22 "2022-02-21T14:09:37Z")

</div>

> [@Hitesh1234](#):
>
> Output is: **undefined**

That is not enough info to help you.

Where do you see this?

What was the value of `msg.payload` BEFORE the function node?  
What was does the full `msg` object look like AFTER the function node?

---

<div class="post-metadata">

**Author:** ![Hitesh1234](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hitesh1234](https://discourse.nodered.org/u/Hitesh1234)\
**Post date:** [21 February 2022 14:12 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/23 "2022-02-21T14:12:43Z")

</div>

```auto
// **msg.payload before the function node** 
var name = msg.payload;
name = name[0]["TEMPERATURE"];
msg.payload =name;
msg.payload = msg.payload.toString();
msg.topic = null;

return msg;

```

I have attached a screenshot which you can see the output.

Thank you in advance.  
 ![output](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8c8bd1b8d152e520b9aacbaf93167b176d7ece12.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:** [21 February 2022 14:13 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/24 "2022-02-21T14:13:47Z")

</div>

> [@Hitesh1234](#):
>
> `// **msg.payload before the function node** `

That is your function code - not the value of `msg.payload`

Put a debug BEFORE the function node, show us the value of `msg.payload` before it enters the function

AND a debug AFTER the function node so we can see the FULL `msg` object (set debug node to show complete message)

---

<div class="post-metadata">

**Author:** ![Hitesh1234](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hitesh1234](https://discourse.nodered.org/u/Hitesh1234)\
**Post date:** [21 February 2022 14:15 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/25 "2022-02-21T14:15:15Z")

</div>

![message](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/2806607a4bcdcf472e139b967a33c2f2c8e1ebfd.png)

THis is the before the function node

---

<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 2022 14:20 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/26 "2022-02-21T14:20:10Z")

</div>

Ok, one last time

Add debug nodes like this...

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

... and give them all names (like "Debug Split Func", "debug request func", "debug http response")

Show use what you get out of all three debug nodes.

---

<div class="post-metadata">

**Author:** ![Hitesh1234](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hitesh1234](https://discourse.nodered.org/u/Hitesh1234)\
**Post date:** [21 February 2022 14:20 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/27 "2022-02-21T14:20:27Z")

</div>

This is after the function node:

`<str val="undefined" />`

---

<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 2022 14:22 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/28 "2022-02-21T14:22:23Z")

</div>

> [@Hitesh1234](#):
>
> This is after the function node:
> 
> `<str val="undefined"`

then the incoming payload is not correct. Do as I asked in previous post (add 3 debugs)

---

<div class="post-metadata">

**Author:** ![Hitesh1234](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hitesh1234](https://discourse.nodered.org/u/Hitesh1234)\
**Post date:** [21 February 2022 14:28 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/29 "2022-02-21T14:28:03Z")

</div>

Thank you.

I have attached. please see it.

 ![All three nodes](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/4727b3469c457b95fc6fb92abb56c3d688f42fe1.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:** [21 February 2022 14:32 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/30 "2022-02-21T14:32:13Z")

</div>

very odd.

2 things...

1. Copy all the code you have inside the "request\_FromNiagra" function **as it is right now** & paste into a reply (remember ````` formatting)
2. Add `node.warn(["msg.payload", msg.payload, typeof msg.payload])` at the TOP of the "request\_FromNiagra" function and try again

show use what you see in the debug sidebar.

---

<div class="post-metadata">

**Author:** ![Hitesh1234](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hitesh1234](https://discourse.nodered.org/u/Hitesh1234)\
**Post date:** [21 February 2022 14:34 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/31 "2022-02-21T14:34:02Z")

</div>

```auto
// assign some variables
username = "obixUser";
password = "Wetec123456#@";
ipAddress = "172.30.34.212";
httpsPort = 443;

//create a base64 digest

authHash = Buffer.from(username+":"+password).toString("base64");

//ordSlot = "/Drivers/SysmikScaIoNetwork/AI4_2/points/Ai3/out/value";
ordSlot = "/Supply$20Fan/NewValue";
//ordSlot = "/Supply$20Fan/p";
// create the message for the get request
operation = "/set";
msg={
    "method": "POST",
    "url": "https://"+ipAddress+":"+httpsPort+"/obix/config"+ordSlot+operation,
    "headers":{
        "Authorization": "Basic" + authHash,
        "Accept":"*/*"
    }
    
};

//ignore cert expired error

msg.rejectUnauthorized = false;

//msg.payload = '<str val ="'+msg.payload+'"/>';

msg.payload = `<str val="${msg.payload}" />`;
return msg;

```

---

<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 2022 14:34 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/32 "2022-02-21T14:34:49Z")

</div>

You still have an error because you DID NOT use [the function code I wrote](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/20) for you.

---

<div class="post-metadata">

**Author:** ![Hitesh1234](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hitesh1234](https://discourse.nodered.org/u/Hitesh1234)\
**Post date:** [21 February 2022 14:38 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/33 "2022-02-21T14:38:09Z")

</div>

Thank you so much.

Now I got the results.

Thank you once again.

---

<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:** [7 March 2022 14:38 UTC](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603/34 "2022-03-07T14:38:44Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/regarding-to-send-a-message-from-node-red-to-niagara-4-framework/58603.md?page=1)
