# Extracting my content value from a msg.payload?

**URL:** <https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182>\
**Category:** General\
**Tags:** http-request\
**Created:** [22 March 2022 08:22 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182 "2022-03-22T08:22:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 08:22 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/1 "2022-03-22T08:22:51Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/26c92bc477d637cfc82443df99b270bf00f63c0d.png)

Am using https request to populate the msg.payload using split node but i want to push the data to MYSQL database before the i am having the error ref screenshot to separate my payload json string to difference outputs

please suggest me

thanks

---

<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:** [22 March 2022 08:52 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/2 "2022-03-22T08:52:32Z")

</div>

Where does that data come from? Have you done something to it to make it like that?

Show us your flow and debug values as the msg passes through the each of nodes

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 10:34 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/3 "2022-03-22T10:34:08Z")

</div>

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

Hi Steve ,

I use HTTP IN node to receive the data using Post method and data json format is convert to Json Object which Json node and i split the msg.payload to get the payload data

---

<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:** [22 March 2022 10:39 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/4 "2022-03-22T10:39:10Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60b17cee767d5232eceb70a094d6fc09164286ce.png)

Use the copy value button  
 ![chrome_aYxpv0MoA9](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/342cd38c2eaabc08ca51eb9b773738f45eb2d1e2.gif)

Paste reply as code block (to prevent format formatting messing up the data)  
`````  
`paste copied value between backticks`  
`````

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 11:12 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/5 "2022-03-22T11:12:30Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/221c7443e25ca7c64a5ee5899c71cc6c47ca6e15.png)

```auto
{"{\"Source\":{\"ReportTime\":\"2022-03-22T11:10:05Z\",\"GroupID\":\"Group 01\",\"DeviceID\":\"SC8131 (0002d18b372f)\",\"ModelName\":\"SC8131\",\"MacAddress\":\"00:02:D1:8B:37:2F\",\"IPAddress\":\"192.168.1.46\",\"TimeZone\":\" 5\",\"DST\":\"0\"},\"Data\":[{\"RuleType\":\"Counting\",\"CountingInfo\":":{"{\"RuleName\":\"Rule\",\"In\":1,\"Out\":1,\"StartTime\":\"2022-03-22T16:39:00 0530\",\"EndTime\":\"2022-03-22T16:40:00 0530\"}":[""]}}

```

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 11:13 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/6 "2022-03-22T11:13:50Z")

</div>

I want to Collect the RuleName, IN ,OUT, STARTTIME,ENDTIME DATA AND publish to MYSQL DATA BASE

Kindly suggest if my Function is not proper

---

<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:** [22 March 2022 11:32 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/7 "2022-03-22T11:32:56Z")

</div>

That looks wrong. A JSON node should convert to or from JSON \< \> object. Your 2 debug nodes both show payload as an object.

1. Can you remove the link between the `HTTP-In` and the `JSON` node - THEN - capture the output again

2. What system calls your endpoint `/users` ? I suspect the JSON is malformed (but still valid).

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 11:38 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/8 "2022-03-22T11:38:39Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f37bcfe3965e86d97f5dcb28691aae2d5144495.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b932072126731d5d44a099f3a4144bb0fce435b6.png)

1. Attached the output again removing the HTTP-IN and JSON node
2. Yea endpoints that referees as /Users.

---

<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:** [22 March 2022 11:50 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/9 "2022-03-22T11:50:32Z")

</div>

@dheeju1314 ....

> [@Steve-Mcl](#):
>
> Can you remove the link between the `HTTP-In` and the `JSON` node - THEN - capture the output again

I wanted you to **DELETE** the link between the `HTTP-In` and the `JSON` node and COPY the PAYLOAD

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

**(7)**  
 ![chrome_aYxpv0MoA9](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/342cd38c2eaabc08ca51eb9b773738f45eb2d1e2.gif)

**(8)**  
Paste reply as code block (to prevent format formatting messing up the data)

```auto
`paste copied value between backticks`

```

> [@dheeju1314](#):
>
> Yea endpoints that referees as /Users.

Sorry, I dont understand your reply - it did not translate well.

I will try to re-word my question...  
2. Which other application calls the node-red endpoint `http://x.x.x.x/users`? I suspect the BODY sent in the POST is malformed JSON (but still valid).

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 12:00 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/10 "2022-03-22T12:00:04Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03a212f2341d1c716ac8ffe3600def642d88ea69.png)  
1.This is the Source am sending data to HTTP IN request  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/0/10bf7dc1e197e334ff8b537330230e522018a232.png)  
2.using this http IN - post node am able to get data at ?users.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e3837d7d81b374f448c69cf0e6a3cdeec33894df.png)  
3. connect debug to HTTP-IN node Output in screenshot  
4. payload:-

```auto
{"{\"Source\":{\"ReportTime\":\"2022-03-22T11:58:05Z\",\"GroupID\":\"Group 01\",\"DeviceID\":\"SC8131 (0002d18b372f)\",\"ModelName\":\"SC8131\",\"MacAddress\":\"00:02:D1:8B:37:2F\",\"IPAddress\":\"192.168.1.46\",\"TimeZone\":\" 5\",\"DST\":\"0\"},\"Data\":[{\"RuleType\":\"Counting\",\"CountingInfo\":":{"{\"RuleName\":\"Rule\",\"In\":2,\"Out\":1,\"StartTime\":\"2022-03-22T17:27:00 0530\",\"EndTime\":\"2022-03-22T17:28:00 0530\"}":[""]}}

```

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 13:04 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/11 "2022-03-22T13:04:13Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/6224a082a6b6acef40cc35b41043db187cd2b80d.jpeg)  
I have go the String value for the reference

---

<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:** [22 March 2022 13:10 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/12 "2022-03-22T13:10:51Z")

</div>

Yes, I know how to convert it - its just trying to help you do the RIGHT thing.

I know how to solve it - but it would be a HACK due to malformed JSON coming in.

_POST data - is badly formed JSON..._

```auto
{
    "{\"Source\":{\"ReportTime\":\"2022-03-22T11:58:05Z\",\"GroupID\":\"Group 01\",\"DeviceID\":\"SC8131 (0002d18b372f)\",\"ModelName\":\"SC8131\",\"MacAddress\":\"00:02:D1:8B:37:2F\",\"IPAddress\":\"192.168.1.46\",\"TimeZone\":\" 5\",\"DST\":\"0\"},\"Data\":[{\"RuleType\":\"Counting\",\"CountingInfo\":": {
        "{\"RuleName\":\"Rule\",\"In\":2,\"Out\":1,\"StartTime\":\"2022-03-22T17:27:00 0530\",\"EndTime\":\"2022-03-22T17:28:00 0530\"}": [
            ""
        ]
    }
}

```

I am trying to find the correct solution for you.

#### What send options does your application have?

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

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 15:08 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/13 "2022-03-22T15:08:00Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c72a48acc3cf4f058b159806a985b8e18d4a0ef.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/6881d4f93edb2cd50528c7649afb524a1c175d5b.png)  
Thanks

please find the refer protocols that can be integrate

---

<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:** [22 March 2022 15:09 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/14 "2022-03-22T15:09:57Z")

</div>

Could you try the XML setting & see what arrives in msg.payload?

Again, capture the debug payload as a string (using the "Copy Value" button) and paste it into a reply. in a ````` `code block` `````

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 15:31 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/15 "2022-03-22T15:31:40Z")

</div>

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

```auto
{"<Message><Source><UtcTime>2022-03-22T15:30:05Z</UtcTime><GroupID>Group 01</GroupID><DeviceID>SC8131 (0002d18b372f)</DeviceID><ModelName>SC8131</ModelName><MacAddress>00:02:D1:8B:37:2F</MacAddress><IPAddress>192.168.1.46</IPAddress><TimeZone> 5</TimeZone><DST>0</DST></Source><Data RuleType":"\"Counting\"></Data><Data RuleType=\"ZoneDetection\"></Data></Message>"}

```

i was configured the option into xml and debug msg comes like this

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 15:32 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/16 "2022-03-22T15:32:24Z")

</div>

for the above reference screenshot data is not coming because not one is there at sensor so msg.payload will be coming like this

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [22 March 2022 15:34 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/17 "2022-03-22T15:34:40Z")

</div>

i have kept this as general but when XML node connected am getting the error as invalid character in name

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f6116d9bfefce36635fd6e3fd2e6796ca697e3b.jpeg)

---

<div class="post-metadata">

**Author:** ![dheeju1314](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@dheeju1314](https://discourse.nodered.org/u/dheeju1314)\
**Post date:** [16 May 2022 11:55 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/18 "2022-05-16T11:55:14Z")

</div>

@Steve-Mcl discussion happend regarding previous screenshots, Looks like am unable to get the proper output still. can you kindly help. what functions need to add to get the proper output for IN and OUT counts

 ![Screenshot from 2022-05-16 17-23-43](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/061ec5448ec7e357128095a00780e32a66f0b067.png)

```auto
payload.In["{\"Source":{"ReportTime":"2022-05-16T11:53:05Z","GroupID":"Group 01","DeviceID":"SC8131 (0002d18b372f)","ModelName":"SC8131","MacAddress":"00:02:D1:8B:37:2F","IPAddress":"192.168.1.50","TimeZone":" 8","DST":"0"},"Data":[{"RuleType":"Counting","CountingInfo":"]["{\"RuleName":"Rule","In":1,"Out":1,"StartTime":"2022-05-16T19:52:00 0800","EndTime":"2022-05-16T19:53:00 0800"}"]

```

---

<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:** [16 May 2022 12:02 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/19 "2022-05-16T12:02:18Z")

</div>

Impossible to say without seeing original data and what is happening inside your function...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7eb453ddf84939a801caa37ffc2426cf7d16578.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:** [15 July 2022 12:02 UTC](https://discourse.nodered.org/t/extracting-my-content-value-from-a-msg-payload/60182/20 "2022-07-15T12:02:39Z")

</div>

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