# Invalid Json - "Unexpected M"

**URL:** <https://discourse.nodered.org/t/invalid-json-unexpected-m/56936>\
**Category:** General\
**Created:** [19 January 2022 21:26 UTC](https://discourse.nodered.org/t/invalid-json-unexpected-m/56936 "2022-01-19T21:26:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete\_hart](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@pete\_hart](https://discourse.nodered.org/u/pete_hart)\
**Post date:** [19 January 2022 21:26 UTC](https://discourse.nodered.org/t/invalid-json-unexpected-m/56936/1 "2022-01-19T21:26:25Z")

</div>

Hey all,

New Here. Quick question- I am looking to hit an API and it expects a Json of data. I am trying to write different parts of the payload to fields in the api call.

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

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

I know im doing something stupid - Any idea what it is?  
Pete

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 January 2022 21:28 UTC](https://discourse.nodered.org/t/invalid-json-unexpected-m/56936/2 "2022-01-19T21:28:42Z")

</div>

You cannot use `msg.xyz` to insert values into a JSON type property.

One alternative is to use the Template node that does support that sort of value substitution.

---

<div class="post-metadata">

**Author:** ![pete\_hart](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@pete\_hart](https://discourse.nodered.org/u/pete_hart)\
**Post date:** [19 January 2022 22:40 UTC](https://discourse.nodered.org/t/invalid-json-unexpected-m/56936/3 "2022-01-19T22:40:52Z")

</div>

Right on. I was able to use a template to format the data into the entire request body:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aa057fcd38ed21068ffa8beb9e25d4cec29646d5.jpeg)  
Is there a way to then pass this to the request body field? Like is there any way to make the request dynamic?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d8ab0b279e4c906aee89b1122d0601c26a5e84a8.png)

Thanks again,  
Pete

---

<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:** [19 January 2022 22:46 UTC](https://discourse.nodered.org/t/invalid-json-unexpected-m/56936/4 "2022-01-19T22:46:54Z")

</div>

What node is that ☝

If you are just doing a HTTP request, you would simply populate msg.payload and pass that to the built in HTTP request node.

---

<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:** [20 March 2022 22:47 UTC](https://discourse.nodered.org/t/invalid-json-unexpected-m/56936/5 "2022-03-20T22:47:37Z")

</div>

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