Body json problem in HTTTP request

HTTP request returns err msg:

Problem in node ‘HTTP Request‘
JSON parameter need to be an valid JSON

using json below:

{
  "token": "{{ $json["token"] }}",
  "idMassa": "{{ $json["idMassa"] }}",
  "priority": {{ $json["priority"] }},
  "interval": {{ $json["interval"] }},
  "emailMsg": "{{ $json["emailMsg"] }}",
  "emailSubject": "{{ $json["emailSubject"] }}",
  "emails": [{{ $json['emails'] }}],
  "SMTP": {
    "nome": "{{ $json["SMTP"]["nome"] }}",
    "email": "{{ $json["SMTP"]["email"] }}",
    "user": "{{ $json["SMTP"]["user"] }}",
    "pwd": "{{ $json["SMTP"]["pwd"] }}",
    "smtp": "{{ $json["SMTP"]["smtp"] }}",
    "port": {{ $json["SMTP"]["port"] }},
    "encryption": "{{ $json["SMTP"]["encryption"] }}",
    "auth": "{{ $json["SMTP"]["auth"] }}",
    "emailReply": "{{ $json["SMTP"]["emailReply"] }}"
  }
}

The problem is here:

"emails": [{{ $json['emails'] }}],

If I change the json as below works fine!

{
  "token": "{{ $json["token"] }}",
  "idMassa": "{{ $json["idMassa"] }}",
  "priority": {{ $json["priority"] }},
  "interval": {{ $json["interval"] }},
  "emailMsg": "{{ $json["emailMsg"] }}",
  "emailSubject": "{{ $json["emailSubject"] }}",
  "emails": [{"email": "[email protected]", "variables": {"nome1": "Lucas"}}],
  "SMTP": {
    "nome": "{{ $json["SMTP"]["nome"] }}",
    "email": "{{ $json["SMTP"]["email"] }}",
    "user": "{{ $json["SMTP"]["user"] }}",
    "pwd": "{{ $json["SMTP"]["pwd"] }}",
    "smtp": "{{ $json["SMTP"]["smtp"] }}",
    "port": {{ $json["SMTP"]["port"] }},
    "encryption": "{{ $json["SMTP"]["encryption"] }}",
    "auth": "{{ $json["SMTP"]["auth"] }}",
    "emailReply": "{{ $json["SMTP"]["emailReply"] }}"
  }
}

The Json above is the same. I just pasted the contents of {{ $json[‘emails’] }} from the json result itself.

What is happening?

  • n8n version: 1.53.2
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Debian 12

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@Lecio_L , the presence of an array breaks your expression. To fix, place the whole JSON into an expression as below

{{
  {
    "token": $json["token"],
    . . ..
    "emails": $json["emails"],
    . . .
  }
}}

Note no quotes (for strings) and no “individual” curly braces. The outer expression will recognize the data type automatically.

2 Likes

Thanks a lot

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