Hey all,
I am trying to send some data from IMAP to discord using http request (Due to sending as an embedded message) And am having issues with sending the data through the webhook.
I am able to get this to work without the ‘{{$json[“Text”]}}’, but need that to bring the input into the message? Unless there is another way to bring the text across.
It worked for a short period but unsure what changed (I have also searched every forum post to try find an answer and cannot)
ERROR: The data in “Body Parameters” is no valid JSON. Set Body Content Type to “RAW/Custom” for XML or other types of payloads
So I suspect this problem could be related to the data you are passing on to your HTTP Request node. Could you share the JSON output of the node just before your HTTP Request node?
Hey @FlippinTurt, I gave this another go with the value you have shared in the Text field but the workflow still runs as expected for me.
Is there any chance you can copy the JSON output from your IF node just before the HTTP Request node? You can do so by selecting the outermost square bracket and then select Copy Value in the upper right.
Of course, any actual text can be redacted but maybe you can leave any special characters in, just to make sure they don’t mess with the workflow execution somehow.
Appreciate the help so far,
See below output from the IF directly before the HTTP, only names changed, no special characters or anything.
As it is seeming to be the text coming through causing the error, would would be the best way to go about changing the text in n8n to allow it through? (Or similar?)
[
{
"Text": "0999728 20:29:17 (STRA123, STRA123, TOKO123) STRU (Alarm Type SMOKE)\r\nCITY HEALTH CENTRE 8 ROAD ST CITY CITY DISTRICT. (XStr\r\nPORTIA ST/MIRANDA ST) #F1234567 - CITY 481\r\n"
}
]
That helps a lot with understanding the problem, thanks for sharing!
So the JSON standard doesn’t allow line breaks, instead they are encoded (in your case with \r\n, the Windows carriage return marker). When using expressions in n8n these encoded line breaks will be decoded (which is in many cases desired, for example when generating email text), but would mean we now have invalid JSON.
A simple way of getting this to work would be to have your expression return an entire JSON object rather than just the string, for example like so:
The Function node just returns the data you have shared, the interesting part is the HTTP Request node: You can see that in the preview it now says Object and your node should run fine: