# Error in payload

**URL:** https://discourse.nodered.org/t/error-in-payload/65715
**Category:** General
**Created:** [27 July 2022 17:53 UTC](https://discourse.nodered.org/t/error-in-payload/65715 "2022-07-27T17:53:20Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sn19](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sn19](https://discourse.nodered.org/u/sn19)
#### Post date: [27 July 2022 17:53 UTC](https://discourse.nodered.org/t/error-in-payload/65715/1 "2022-07-27T17:53:21Z")

</div>

What causes the following error and how do I fix it ?

msg : error

"TypeError: Cannot read properties of undefined (reading 'split')"

---

<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: [27 July 2022 18:31 UTC](https://discourse.nodered.org/t/error-in-payload/65715/2 "2022-07-27T18:31:06Z")

</div>

An undefined property that a script is trying to read another property from, often hard to pin point with no info.

---

<div class="post-metadata">

### Author: ![sn19](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sn19](https://discourse.nodered.org/u/sn19)
#### Post date: [27 July 2022 18:56 UTC](https://discourse.nodered.org/t/error-in-payload/65715/3 "2022-07-27T18:56:14Z")

</div>

What info would you like to know? I am using .json format as input

{

```
            "name" : "Integer001",

            "value" :"1444535466",
            
           
            "type" : "int32"

        },

```

and more objects 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: [27 July 2022 19:11 UTC](https://discourse.nodered.org/t/error-in-payload/65715/4 "2022-07-27T19:11:24Z")

</div>

What you are attempting to do?  
What nodes are you using?  
What are your inputs?  
What output you expect?  
Maybe a flow json.  
what operating system?  
What node is producing the error?  
Any code you may be using.  
Maybe then someone might pin point what's causing your error.

---

<div class="post-metadata">

### Author: ![sn19](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sn19](https://discourse.nodered.org/u/sn19)
#### Post date: [27 July 2022 19:32 UTC](https://discourse.nodered.org/t/error-in-payload/65715/5 "2022-07-27T19:32:22Z")

</div>

I am attempting to establish an MQTT communication with Sparkplug B specification

The nodes I am using are inject, function, Sparkplug plus publisher, subscriber and debug (payload) node.

The input is a .json code sent via the function block

```auto
msg.payload = {
        "timestamp" : 1504739061501,
        "metrics" : [
            {
                "name" : "Integer001",
                "value" :"1444535466",                               
                "type" : "int32"
            },            
            {
                "name" : "String001",
                "value" : "hello",
                "type" : "string"
            },            
            {
                "name" : "Boolean001",
                "value" : "true",
                "type" : "boolean"
            },            
            {
                "name" : "Float001",
                "value" :"192.192",                               
                "type" : "float"
            }                      
        ]
    };    
return msg;

```

I expect output to be structured objects

OS is Windows 10 Pro

Debug node is producing the error

* * *

_{Admin edit: wrap code in a ````` codeblock}_

---

<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: [27 July 2022 19:51 UTC](https://discourse.nodered.org/t/error-in-payload/65715/6 "2022-07-27T19:51:03Z")

</div>

> [@sn19](#):
>
> The input is a .json code sent via the function block
> 
> ```auto
> msg.payload = {
> "timestamp" : 1504739061501,
> "metrics" : [
> {
> "name" : "Integer001",
> "value" :"1444535466",                               
> "type" : "int32"
> },            
> {
> "name" : "String001",
> "value" : "hello",
> "type" : "string"
> },            
> {
> "name" : "Boolean001",
> "value" : "true",
> "type" : "boolean"
> },            
> {
> "name" : "Float001",
> "value" :"192.192",                               
> "type" : "float"
> }                      
> ]
> };    
> return msg;
> 
> ```

it is perfectly valid...

> [@sn19](#):
>
> I expect output to be structured objects

And it is...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58da64f0b61f12c9e39041037a1192b04295ca4a.png)

> [@sn19](#):
>
> Debug node is producing the error

If the msg is reaching a debug node, then it is not likely an error in the function - rather something else!

  

You are going to have to share more info (i.e. export a flow or at minimum a screenshot)

---

<div class="post-metadata">

### Author: ![sn19](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sn19](https://discourse.nodered.org/u/sn19)
#### Post date: [27 July 2022 19:53 UTC](https://discourse.nodered.org/t/error-in-payload/65715/7 "2022-07-27T19:53:36Z")

</div>

Thank you @Steve-Mcl its working now without any errors. I figured out a fix for it and while the .json format was fine by itself , msg.payload could only be used with as a function block. when I try to use the same .json code in the inject node as a .json input itr gives me error unless I remove the msg.paylaod line and return.msg line.

---

<div class="post-metadata">

### Author: ![sn19](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sn19](https://discourse.nodered.org/u/sn19)
#### Post date: [27 July 2022 19:54 UTC](https://discourse.nodered.org/t/error-in-payload/65715/8 "2022-07-27T19:54:40Z")

</div>

I am trying to come up with a code or node red flow so that I'd be able to setup SparkplugB based MQTT protocol by making use of the ignition broker.

---

<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: [27 July 2022 19:58 UTC](https://discourse.nodered.org/t/error-in-payload/65715/9 "2022-07-27T19:58:30Z")

</div>

> [@sn19](#):
>
> msg.payload could only be used with as a function block

Yes, that is a very basic node-red knowledge.

In an inject you would enter `payload` since the entry is already prefixed with `msg.`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/9613d00be92e2581240af9eff712502b86b40917.png)

---

<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: [25 September 2022 19:58 UTC](https://discourse.nodered.org/t/error-in-payload/65715/10 "2022-09-25T19:58:40Z")

</div>

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