I am passing email received in Gmail (via a Gmail Trigger) to an HTTP Request node that connects to a CRM API. However the html body of the email is breaking the request due to the lack of encoding of the html. Specifically, things like “” within or line feeds etc.
{
“data”: {
“type”: “Emails”,
“attributes”: {
“name”: “my email subject”,
“description”: "
From: Bob Smart <[email protected]>
Date: Thu, 24 Apr 2025 at 12:10
Subject: Important: Request for Client Information
To: <[email protected]>
……
Regards,
Bob Smart
Other posts have suggested inserting a SET node between the gmail message and the http request. This seems to have no affect as the new field used in the Set node still does not transform the text.
{
“data”: {
“type”: “Emails”,
“attributes”: {
“name”: “my email subject”,
“Htmlbody”: “{{ $json [“myhtml”] }}”,
“from_addr”: “[email protected]”
}
}
}
I have tried using {{JSON stringify…. But this also fails or I’m unsure where/how to use it
I have tried a CODE node with Javascript to try and write the body of the HTTP Request however the HTTP Request is not expecting an Array object
const html = $json.html;
return {
data: {
type: “Emails”,
attributes: {
name: “Fwd: Important…”,
from_addr: “[email protected]”,
Htmlbody: html
}
}
};
ERROR when running HTTP Request is
Problem in node ‘HTTP Request‘ JSON parameter needs to be valid JSON
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.88
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: