Problem with an http request (JSON parameter need to be a valid JSON) . In variables

JSON parameter need to be a valid JSON

Guys, I hope you find it well.

I’m making a request on n8n and for some reason it’s not accepting my variables and it gives an error in the JSON.

First I was pulling them from an Excel, then now I created a SET node to try and see if it worked, but it doesn’t work.

I did a test in another workflow with the same request but without the variables (expressions) and it works.

Does anybody know how to solve this?

[https://aawz.app.n8n.cloud/workflow/PiOqX1TwqMZuibMc/executions/57]


{
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “8f15dc730c58cd2eb5917ce235e3dee955c5e1e6d48924c721d3be25bba46505”
},
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “https://crm.rdstation.com/api/v1/tasks?token=66534df919eb1d0012fec498”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “accept”,
“value”: “application/json”
},
{
“name”: “content-type”,
“value”: “application/json”
}
]
},
“sendBody”: true,
“specifyBody”: “json”,
“jsonBody”: “={\n "task": {\n "date": "{{ $(‘Edit Fields’).item.json[‘Due Date’] }}",\n "deal_id": "{{ $(‘Edit Fields’).item.json.ID }}",\n "done": true,\n "hour": "{{ $(‘Edit Fields’).item.json.Hora }}",\n "notes": "{{ $(‘Edit Fields’).item.json.Notas }}",\n "subject": "{{ $json.Tipo }}",\n "type": "task"\n }\n}\n”,
“options”: {}
},
“id”: “aa6d7b0f-9bde-4b9c-a175-8de824b192d1”,
“name”: “Criando tarefa como concluida1”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.1,
“position”: [
2040,
240
]
}
],
“connections”: {},
“pinData”: {}
}


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:

n8n Version 1.41.1
Banco de dados (padrão: SQLite)
Configuração n8n EXECUTIONS_PROCESS
Executando n8n via (Docker, npm, n8n cloud, aplicativo de desktop)
I don’t know yet, I’m on trial.

Using just an excel and an http request

Operating system: Windows 11 Home Single Language, Versão 23H2, Compilação do SO 22631.3593

@mateus.silva , turn the whole JSON into the expression and remove the quotes and the double curly braces from where they are now. That is, it should look like this

{{
  {
    "task": {
      "date": $....,
      "deal_id": $...
      . . .
    }
  }
}}


Thus?

I did not work :confused:

[(https://aawz.app.n8n.cloud/workflow/PiOqX1TwqMZuibMc)](https://aawz.app.n8n.cloud/workflow/PiOqX1TwqMZuibMc)

I wanted to paste my workflow here to help. But I don’t think I managed.

PiOqX1TwqMZuibMc

type or paste code here

@mateus.silva , no, not like that. Take a look at my example again. The whole JSON has to be turned into an expression. That is, it has to be enclosed with double curly braces

{{
  YOUR JSON GOES HERE
}}

@ihortom unsuccessfully.

{ {
{
“task”: {
“date”: $(‘Google Sheets’).item.json[‘Due Date’],
“deal_id”: $(‘Edit Fields’).item.json.ID,
“done”: false,
“hour”: $(‘Google Sheets’).item.json[‘Hora due’],
“notes”: $(‘Google Sheets’).item.json.Notas,
“subject”: $(‘Google Sheets’).item.json.Tipo,
“type”: task
}
}
}}

@mateus.silva , it’s a different error now. The HTTP Request node in the last workflow you shared has an extra space in between double curly braces and thus it is not a valid expression. Also, the word “task” is missing the quotes. I asked to remove the quotes from expressions only, not the regular string values.

{ {  // you have extra space between {{
{
  "task": {
    "date": $('Google Sheets').item.json['Due Date'],
    "deal_id": $('Edit Fields').item.json.ID,
    "done": false,
    "hour": $('Google Sheets').item.json['Hora due'],
    "notes": $('Google Sheets').item.json.Notas,
    "subject": $('Google Sheets').item.json.Tipo,
    "type": task   // it has to be "task", not just task
  }
}
} }  // you have extra space between }}

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