# Writing a Json Message

**URL:** <https://discourse.nodered.org/t/writing-a-json-message/68684>\
**Category:** General\
**Tags:** database\
**Created:** [7 October 2022 13:29 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684 "2022-10-07T13:29:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akule8](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Akule8](https://discourse.nodered.org/u/Akule8)\
**Post date:** [7 October 2022 13:29 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/1 "2022-10-07T13:29:21Z")

</div>

Hey,  
I am new to node red and have no experience with it. So my questions are: How can I write a JSON-Message and integrate it into an insert-statement? Furthermore, how can i transfer a Message into a Postgres Database?

---

<div class="post-metadata">

**Author:** ![Dumy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dumy/32/50320_2.png) [@Dumy](https://discourse.nodered.org/u/Dumy)\
**Post date:** [7 October 2022 13:40 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/2 "2022-10-07T13:40:10Z")

</div>

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

Code:

```auto
[{"id":"43a7968a456ad836","type":"inject","z":"bba055f91ed61523","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"hello\":\"word\"}","payloadType":"json","x":350,"y":560,"wires":[["b1c5f77a335127f4"]]},{"id":"b1c5f77a335127f4","type":"postgresql","z":"bba055f91ed61523","name":"","query":"INSERT INTO table_name(column1)\nVALUES ('{{{payload.hello}}}');","postgreSQLConfig":"1e4da63817fa609c","split":false,"rowsPerMsg":1,"outputs":1,"x":570,"y":560,"wires":[["14946f51cb515194"]]},{"id":"14946f51cb515194","type":"debug","z":"bba055f91ed61523","name":"debug 77","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":560,"wires":[]},{"id":"1e4da63817fa609c","type":"postgreSQLConfig","name":"","host":"localhost","hostFieldType":"str","port":"5432","portFieldType":"num","database":"postgres","databaseFieldType":"str","ssl":"true","sslFieldType":"bool","applicationName":"","applicationNameType":"str","max":"10","maxFieldType":"num","idle":"1000","idleFieldType":"num","connectionTimeout":"10000","connectionTimeoutFieldType":"num","user":"username","userFieldType":"str","password":"password","passwordFieldType":"str"}]

```

You need to install this node:  
[node-postgresql](https://flows.nodered.org/node/node-red-contrib-postgresql)

exemple insert:

```auto
INSERT INTO table_name(column1)
VALUES ('{{{payload.hello}}}');

```

---

<div class="post-metadata">

**Author:** ![Akule8](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Akule8](https://discourse.nodered.org/u/Akule8)\
**Post date:** [7 October 2022 19:11 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/3 "2022-10-07T19:11:02Z")

</div>

Thank you very much for your help.  
When i try to deploy it, i get a "Error: certificate has expired" Message. Do you know how i can resolve it?

---

<div class="post-metadata">

**Author:** ![Dumy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dumy/32/50320_2.png) [@Dumy](https://discourse.nodered.org/u/Dumy)\
**Post date:** [8 October 2022 22:48 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/4 "2022-10-08T22:48:30Z")

</div>

I don't understand at what node you received this message?

---

<div class="post-metadata">

**Author:** ![Akule8](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Akule8](https://discourse.nodered.org/u/Akule8)\
**Post date:** [9 October 2022 16:58 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/5 "2022-10-09T16:58:52Z")

</div>

The Error occurs at the postresql node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 October 2022 12:39 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/6 "2022-10-10T12:39:25Z")

</div>

I see that you have specified SSL true in the server node config. I haven't used that node, but I wonder whether that is part of the problem. Did you intentionally set SSL?

---

<div class="post-metadata">

**Author:** ![Akule8](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Akule8](https://discourse.nodered.org/u/Akule8)\
**Post date:** [11 October 2022 08:33 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/7 "2022-10-11T08:33:16Z")

</div>

Thank you. This was apparently the Problem. After setting the checkbox to False, the message didnt appear anymore.  
It seems however that a new row is injected at my Database but without the message.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1e07f5f5f895811876ad9799a16134db2cbfae5.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4d50993c0c29490151fc1f019f75e08b5c4f40a.png)  
What have i done wrong?

---

<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:** [10 December 2022 08:34 UTC](https://discourse.nodered.org/t/writing-a-json-message/68684/8 "2022-12-10T08:34:01Z")

</div>

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