Http request Node stopped working with cyrillic

#1

This code has always worked:

Summary
[{"id":"2305c42f.da47a4","type":"http request","z":"37a4cfd0.689588","name":"TEST DOOR","method":"POST","ret":"txt","url":"http://192.168.1.2:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=\"QERFWrtrg4t5\"&payload={\"text\": \"кирилица\"}","tls":"","x":430,"y":180,"wires":[["c0fe87d3.f0429"]]},{"id":"c0fe87d3.f0429","type":"debug","z":"37a4cfd0.689588","name":"Door Sensor Status","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":660,"y":180,"wires":[]},{"id":"871407db.981758","type":"inject","z":"37a4cfd0.689588","name":"","topic":"","payload":"true","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":180,"wires":[["2305c42f.da47a4"]]}]

I'm sending webhook url to http request Node

http://192.168.1.2:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token="QERFWrtrg4t5"&payload={"text": "кирилица"}

And it always worked.
Recently it stopped working, if the message contains at least one Cyrillic character.

Log
|node-red.0|2019-01-27 22:12:01.260|error|at processImmediate [as _immediateCallback] (timers.js:745:5)|
|---|---|---|---|
|node-red.0|2019-01-27 22:12:01.260|error|at tryOnImmediate (timers.js:768:5)|
|node-red.0|2019-01-27 22:12:01.260|error|at runCallback (timers.js:810:20)|
|node-red.0|2019-01-27 22:12:01.260|error|at Immediate.<anonymous> (/opt/iobroker/node_modules/request/request.js:578:7)|
|node-red.0|2019-01-27 22:12:01.260|error|at end (/opt/iobroker/node_modules/request/request.js:549:18)|
|node-red.0|2019-01-27 22:12:01.260|error|at Request.write (/opt/iobroker/node_modules/request/request.js:1497:10)|
|node-red.0|2019-01-27 22:12:01.260|error|at Request.start (/opt/iobroker/node_modules/request/request.js:751:32)|
|node-red.0|2019-01-27 22:12:01.260|error|at Object.request (http.js:39:10)|
|node-red.0|2019-01-27 22:12:01.260|error|at new ClientRequest (_http_client.js:137:13)|
|node-red.0|2019-01-27 22:12:01.260|error|27 Jan 22:12:01 - [error] [http request:TEST DOOR] TypeError: Request path contains unescaped characters|
Debug messages
msg : error
"TypeError: Request path contains unescaped characters"
msg.payload : string[247]
"TypeError: Request path contains unescaped characters : http://192.168.1.2:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token="QERFWrtrg4t5"&payload={"text": "кирилица"}"

If you remove the Cyrillic alphabet "кирилица" and insert any Latin characters, eg "123QWERty", then everything works successfully.
Why stopped working with Cyrillic?

0 Likes

#2

problem solved:

msg.CyrillicMessage = encodeURIComponent('Привет Мир');
return msg;
Summary
[{"id":"20b1742.e00da8c","type":"http request","z":"64e8a21a.233f3c","name":"","method":"POST","ret":"txt","url":"http://192.168.1.2:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=%22TvDtggrtGr%22&payload={\"text\": \"{{{CyrillicMessage}}}\"}","tls":"","x":830,"y":160,"wires":[["9039465f.edbf18"]]},{"id":"9039465f.edbf18","type":"debug","z":"64e8a21a.233f3c","name":"Door Sensor Status","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":1040,"y":160,"wires":[]},{"id":"ae787e2c.09a418","type":"inject","z":"64e8a21a.233f3c","name":"","topic":"","payload":"true","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":160,"wires":[["8ec1277c.0cdf2"]]},{"id":"8ec1277c.0cdf2","type":"function","z":"64e8a21a.233f3c","name":"Текст сообщения","func":"msg.CyrillicMessage = encodeURIComponent('Привет Мир');\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":160,"wires":[["c6325ef1.f616b","20b1742.e00da8c"]]},{"id":"c6325ef1.f616b","type":"debug","z":"64e8a21a.233f3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"CyrillicMessage","x":860,"y":100,"wires":[]}]
0 Likes