# HowTo POST HTTP request Synology Chat

**URL:** <https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694>\
**Category:** General\
**Created:** [13 November 2021 18:48 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694 "2021-11-13T18:48:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cavekeeper](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Cavekeeper](https://discourse.nodered.org/u/Cavekeeper)\
**Post date:** [13 November 2021 18:48 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694/1 "2021-11-13T18:48:02Z")

</div>

My goal is to send an HTTP command to the Synology Chat bot.  
In Synology's cookbook, it is described as follows.

Place the JSON string after the payload application / x-www-form-urlencoded data parameter to the webhook url. Example:

```auto
POST https://DS_IP/webapi/entry.cgi?api=SYNO.Chat.External&XXXXX Content-Type: application/x-www-form-urlencoded payload=%7B%22text%22%3A%22This%20is%20a%20test.%22%7D

```

Below is an example of CURL:

```auto
curl -X POST \ --data-urlencode 'payload={"text": "This is a test"}' \ https://DS_IP/webapi/entry.cgi?api=SYNO.Chat.External&XXXXX

```

Now I've got it with the CURL as follows. This is how it works with CURL:  
 ![Bildschirmfoto 2021-11-13 um 19.37.15](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/556d739f81f35c0b7e575f74ca58d3ab9c6ec97c.png)

```auto
[{"id":"ebd7f583394363ac","type":"inject","z":"8ed57a821485ba05","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":100,"y":1000,"wires":[["eaa380d9.07f03"]]},{"id":"eaa380d9.07f03","type":"template","z":"8ed57a821485ba05","name":"SynoChat","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" curl -X POST \"http://192.168.178.10:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=%2236rQjLXdWCSZPPqIS0GW3ZvmarvKdlRMLXXJrRcWq9vjQYH16HkozhFFXIVtgVBN%22\" \\\n -H \"Content-Type: application/x-www-form-urlencoded\" \\\n --data-urlencode 'payload={\"text\": \"This is a test\"}'\n","output":"str","x":300,"y":1000,"wires":[["e5236a1a.6e8fe8"]]},{"id":"e5236a1a.6e8fe8","type":"exec","z":"8ed57a821485ba05","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":530,"y":1000,"wires":[["7573266c35d80c6c"],[],[]]}]

```

Now I thought to myself that it should actually work with the HTTP request. My attempts look like this. Unfortunately I haven't had any success with that yet.  
 ![Bildschirmfoto 2021-11-13 um 19.42.37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21f541006bd3b456edddc6e321c646f1d8af8454.png)

```auto
[{"id":"9fd5792ee92e48fe","type":"http request","z":"8ed57a821485ba05","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.178.10:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=%2236rQjLXdWCSZPPqIS0GW3ZvmarvKdlRMLXXJrRcWq9vjQYH16HkozhFFXIVtgVBN%22","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":510,"y":880,"wires":[[]]},{"id":"5a4ab97bf3103393","type":"change","z":"8ed57a821485ba05","name":"SynoChat","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"content-type\":\"application/x-www-form-urlencoded\"}","tot":"json"},{"t":"set","p":"payload","pt":"msg","to":"{\"text\":\"This is a test\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":880,"wires":[["9fd5792ee92e48fe"]]},{"id":"ebd7f583394363ac","type":"inject","z":"8ed57a821485ba05","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":140,"y":880,"wires":[["5a4ab97bf3103393"]]}]

```

The following error message then appears:

```auto
{"error":{"code":120,"errors":{"name":"payload","reason":"required"}},"success":false}

```

Since it works with the CURL command, it should also work with the HTTP command. Is anyone able to help me?

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 November 2021 19:58 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694/2 "2021-11-13T19:58:27Z")

</div>

The error is clear .. it expects a `payload` in the posted data  
so in your Change node try :

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

a bit confusing because in NR `payload` is part of the msg sent .. but the POST needs a nested payload string for that property

---

<div class="post-metadata">

**Author:** ![Cavekeeper](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Cavekeeper](https://discourse.nodered.org/u/Cavekeeper)\
**Post date:** [14 November 2021 08:18 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694/3 "2021-11-14T08:18:16Z")

</div>

Yes, that has fixed the error.  
But now I get another error:

```auto

{"error":{"code":404,"errors":"invalid token"},"success":false}

```

The token has not changed. It is the same as for the CURL flow. And there it works.  
So I guess the header should be urlencode?  
But it is also setup.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [14 November 2021 13:14 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694/4 "2021-11-14T13:14:08Z")

</div>

hi .. surely there must be something wrong with the token  
try to remove the `%22` from the beginning and end of your token= in the URL in the Http request node  
as these are the `"` character .. possibly not needed.

---

<div class="post-metadata">

**Author:** ![Cavekeeper](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Cavekeeper](https://discourse.nodered.org/u/Cavekeeper)\
**Post date:** [14 November 2021 14:40 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694/5 "2021-11-14T14:40:34Z")

</div>

Hi, I have solved the problem. There was actually something wrong with the token. I generated and inserted a new one. Why ever that happened. Now it's working. I didn't need to remove the characters% 22. Thank you for your help.

---

<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:** [28 November 2021 14:41 UTC](https://discourse.nodered.org/t/howto-post-http-request-synology-chat/53694/6 "2021-11-28T14:41:12Z")

</div>

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