An HTML string is partially interpreted when referenced in an HTTP request node

Hello everyone !

I am currently working on a process to autofill so product informations to send to one of our API. During our workflow, I add some a description written in HTML to the HTTPS requests.

You can see in the Set node that the longDescription data is fully written in HTML which is what I want.

However, when I reference this data in my HTTPS request node, I can see that the HTML is automatically detected and my text gets formatted accordingly, thus impeaching to send the HTTPS request as my body is not correctly formatted for the JSON (I get the message : ERROR: JSON parameter need to be an valid JSON). For instance, if I have some /n in my string on the SET node, I get a line break when it gets referenced on the HTTPs JSON request body which breaks the format.

How can I keep the HTML intact from my set node when referencing it in my JSON body ?

Thanks everyone

Here is my nodes :

Information on your n8n setup

  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • N8N cloud
  • Windows 11

hi @Romain_Mangattale,
you can try to use this syntax:

   "longDescription": {{ JSON.stringify($json.longDescription) }}

JSON.stringify() should be able to convert HTML to a valid JSON string.

I paste you here a demo workflow for reference:

Hope it helps, let me know if this solved your problem.

1 Like

Hello !

Yes, it works perfectly ! Thanks a lot. It would be interesting to be able to find the HTML automatic formatting in the documentation ^^


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