# Failing in creating a JSON when the example I'm following is working

**URL:** <https://discourse.nodered.org/t/failing-in-creating-a-json-when-the-example-im-following-is-working/65374>\
**Category:** General\
**Created:** [20 July 2022 15:21 UTC](https://discourse.nodered.org/t/failing-in-creating-a-json-when-the-example-im-following-is-working/65374 "2022-07-20T15:21:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vongomben](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Post date:** [20 July 2022 15:21 UTC](https://discourse.nodered.org/t/failing-in-creating-a-json-when-the-example-im-following-is-working/65374/1 "2022-07-20T15:21:19Z")

</div>

Hi!  
I'm following [this](https://nerdiy.de/en/nodered-magicmirror-daten-von-nodered-auf-dem-mirror-anzeigen/) tutorial on creating a JSON to be later embedded in a mirror.  
[Here is the code](https://gist.github.com/vongomben/d5c1c9be68cf7c526fed3793bd883563) with english translated comments. it works super fine.

When I'm trying to embed a string coming from a telegram bot (and in [this example simply injected and passed to a flow level variable](https://gist.github.com/vongomben/4000a5047e21f89d34eee9a2758eb90e)) the json I can access browsing the ip-adddress/telegram.json is not populated with my data. How comes?  
What am I missing?

---

<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:** [20 July 2022 15:46 UTC](https://discourse.nodered.org/t/failing-in-creating-a-json-when-the-example-im-following-is-working/65374/2 "2022-07-20T15:46:16Z")

</div>

The template does not see message or message\_time as you have not set them or retieved them from flow context.  
Either  
set them with a change node before hand or you could use `{{flow.message}}`

e.g.

```auto
[{"id":"cc88641a14c03bc7","type":"http in","z":"30af2d3e.d94ea2","name":"","url":"/telegram.json","method":"get","upload":false,"swaggerDoc":"","x":190,"y":1440,"wires":[["1ad639b1.8b7646"]]},{"id":"1ad639b1.8b7646","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"message","pt":"msg","to":"message","tot":"flow"},{"t":"set","p":"message_time","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":1440,"wires":[["90a21e3a43bac0c9"]]},{"id":"90a21e3a43bac0c9","type":"template","z":"30af2d3e.d94ea2","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{ \n \"telegram\": [\n {\n \"message\": \"{{message}}\",\n \"lastUpdate\": \"{{message_time}}\"\n }\n]\n}","output":"str","x":570,"y":1440,"wires":[["344ef76f2d841121"]]},{"id":"344ef76f2d841121","type":"change","z":"30af2d3e.d94ea2","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1440,"wires":[["34e07d0f670651b9"]]},{"id":"34e07d0f670651b9","type":"http response","z":"30af2d3e.d94ea2","name":"","statusCode":"","headers":{},"x":900,"y":1440,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![vongomben](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Post date:** [20 July 2022 15:49 UTC](https://discourse.nodered.org/t/failing-in-creating-a-json-when-the-example-im-following-is-working/65374/3 "2022-07-20T15:49:44Z")

</div>

ah!  
Thanks. Yes. 🤐 🤦‍♂️ 🙏

---

<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:** [18 September 2022 15:50 UTC](https://discourse.nodered.org/t/failing-in-creating-a-json-when-the-example-im-following-is-working/65374/4 "2022-09-18T15:50:02Z")

</div>

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