# Msg.payload undefined - message object

**URL:** <https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985>\
**Category:** General\
**Created:** [17 November 2018 21:36 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985 "2018-11-17T21:36:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbee112](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@newbee112](https://discourse.nodered.org/u/newbee112)\
**Post date:** [17 November 2018 21:36 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/1 "2018-11-17T21:36:33Z")

</div>

Hi,  
I have been stuck on this problem for hours. It is probably an easy thing to solve, but the forum nor google resulted in a solution.

when i debug the node i get the following:  
2018-11-17 22:28:18 node: msg.payload : undefined  
undefined

when i look at full message i get the following:  
2018-11-17 22:28:18[ ode: msg : Object  
{ class: "sensor", protocol: "fineoffset", id: 247, model: "temperaturehumidity", humidity: 45 …}

If i expand it looks like this:  
2018-11-17 22:28:18 node: msg : Object  
object  
class: "sensor"  
protocol: "fineoffset"  
id: 247  
model: "temperaturehumidity"  
humidity: 45  
temp: 26.5  
\_msgid: "e1432419.b8f6f8"

All i want to do is to get the humidity and temp into msg.payload so i can use the values further in the flow.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 November 2018 21:57 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/2 "2018-11-17T21:57:30Z")

</div>

Do you mean you are starting with the message that you have shown and you want to end up with the payload being an object containing just the temperature and humidity?  
If so then you want something like

```auto
msg.payload = {humidity: msg.humidity, temp: msg.temp}
return msg

```

---

<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:** [17 November 2018 21:57 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/3 "2018-11-17T21:57:34Z")

</div>

Slightly odd that the source provides the data like that... but...  
simplest would be to use a change node to move msg.temp to msg.payload.temp and likewise humidity.

(or indeed a small function as per Colin's post above)

---

<div class="post-metadata">

**Author:** ![newbee112](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@newbee112](https://discourse.nodered.org/u/newbee112)\
**Post date:** [18 November 2018 08:17 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/4 "2018-11-18T08:17:36Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![tbet](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tbet](https://discourse.nodered.org/u/tbet)\
**Post date:** [16 December 2020 21:45 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/5 "2020-12-16T21:45:04Z")

</div>

Hi,  
I have a similar question, so I just didn't open a new threat.

I tried do get data from Ubidots, but I'm not able to get the data into my msg.payload.

If I activate node-state, I get following result:

{ data\_1: { value:0 } }

 ![16081558467493773897564368775530](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8cfb93a26fadec97815b5c990ee427a9450bf427.jpeg)

The communication between ubidots and nodered works well. It's just this little problem I can't solve yet.

Thanks for help.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 December 2020 22:03 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/6 "2020-12-16T22:03:23Z")

</div>

Welcome to the forum @tbet.

You haven't said what the problem is. Note that in the debug window if you click on `object` it will expand that so you can see what is there. If you don't know how to get the data out of the object (if that is what you need to do) have a read of the node-red docs page Working with Messages which will help you to do that. Also, if you are a beginner then watch the excellent Node red Essentials videos linked from the node red docs.

---

<div class="post-metadata">

**Author:** ![tbet](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tbet](https://discourse.nodered.org/u/tbet)\
**Post date:** [16 December 2020 22:45 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/7 "2020-12-16T22:45:34Z")

</div>

Hi Colin, thanks for your quick answer.

What I want at the end is to write the value of the variable that I get from Ubidots into a variable existing at PLC S7-1500.  
The connection to PLC already works, but what I need is to format the Ubidots input _message_ into boolean value that I can work with.

I just want to exclude the rest of the message that there is only the 0 (false) or 1 (true).

All in all I just want to convert "{ data\_1: { value:0} }" into "0".

Thanks.

---

<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:** [16 December 2020 23:10 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/8 "2020-12-16T23:10:03Z")

</div>

So yes - you can use a change node to move the property you want to the payload - and as Colin said

> [@Colin](#):
>
> read the node-red docs page Working with Messages

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

as that will give you all you need to work out how to access the value.

---

<div class="post-metadata">

**Author:** ![tbet](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tbet](https://discourse.nodered.org/u/tbet)\
**Post date:** [16 December 2020 23:37 UTC](https://discourse.nodered.org/t/msg-payload-undefined-message-object/4985/9 "2020-12-16T23:37:07Z")

</div>

Thanks for your hints. I got it.
