# Sending JSON body with template node

**URL:** https://discourse.nodered.org/t/sending-json-body-with-template-node/58865
**Category:** General
**Created:** [23 February 2022 09:51 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865 "2022-02-23T09:51:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)
#### Post date: [23 February 2022 09:51 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865/1 "2022-02-23T09:51:23Z")

</div>

Hi,

I am trying to send an JSON body to my HTTP request. But I need to give a percentage in the body, that's the reason why I use the template node.  
When I deploy I get an error "Unexpected end of JSON input", does anyone know what the problem is?

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

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

---

<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: [23 February 2022 09:58 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865/2 "2022-02-23T09:58:52Z")

</div>

You are missing the closing `} }` at the end of the template.

You should also be setting `msg.payload` not `msg.req.body` if you want the HTTP Request node to send it.

---

<div class="post-metadata">

### Author: ![Milanovic](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Milanovic](https://discourse.nodered.org/u/Milanovic)
#### Post date: [23 February 2022 10:05 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865/3 "2022-02-23T10:05:43Z")

</div>

I tried but, still the same error

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

---

<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: [23 February 2022 10:14 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865/4 "2022-02-23T10:14:19Z")

</div>

I suggest you turn off the "parsed JSON object" option, then pass the output to a Debug node so you can see the actual text being generated. That'll make it much easier to spot the error.

---

<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: [23 February 2022 11:10 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865/5 "2022-02-23T11:10:00Z")

</div>

I think the `msg.payload.percentage` should be `payload.percentage` when using template node.  
[edit] and \</\> format need to be mustache

---

<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: [24 April 2022 11:10 UTC](https://discourse.nodered.org/t/sending-json-body-with-template-node/58865/6 "2022-04-24T11:10:40Z")

</div>

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