Http Request Body Parameters is no valid JSON

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

Information on your n8n setup

  • 0.170.0
  • SQLite
  • Running n8n via Docker on UNraid

Appreciate any help

Hi @FlippinTurt, welcome to the community!

I am sorry to hear you’re having trouble here. I tried running the node with some dummy data but didn’t run into trouble here:

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?

1 Like

Cheers for the reply :slight_smile:

I was suspecting that, however some it worked on and some it didn’t (although none work now)- so I am not too sure what is causing it

Most of the JSON output before the HTTP is around the lines of the below;

0999027 10:12:18  REGION DISTRICT. (XStr Road LA/) .LIGHT AIRCRAFT CRASH OFF AIRFIELD. #F123456 - MOTU123 

This is what the whole workflow looks like, the first IF just checks what email the data is coming from

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.

Thank you!

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"
1 Like

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:

1 Like

Well that got the HTTP sending :smiley:
Thank you again for this, it’s taken me forever lol.

Next problem is it’s not sending the data to discord - it leaves the function fine as far as I can see

Hey @FlippinTurt,

For the data you are sending in the HTTP Request node try this…

  "content": null,
  "embeds": [
    "title": ":fire:FIRE:fire:",
    "description": '{{$json["Text"]}}',
    "color": 16579585

OMG, I am so sorry - looks like I copied an older version of my workflow :face_with_open_eyes_and_hand_over_mouth: Here you go:

Double-checked, this sends the right value:


@MutedJam @Jon
All working as it should now,
Thank you both heaps!
Appreciate it :smiley:


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