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

**URL:** <https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340>\
**Category:** Questions\
**Tags:** expressions\
**Created:** [May 28, 2024, 8:18pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340 "2024-05-28T20:18:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.n8n.io/u/mateus.silva)\
**Post date:** [May 28, 2024, 8:18pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/1 "2024-05-28T20:18:27Z")

</div>

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?

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

```

 ![Captura de tela 2024-05-28 165947](https://europe1.discourse-cdn.com/n8n/original/3X/e/5/e54aac6786014a9b5aef8fbaceb5865e7eedefc6.png)  
 ![Captura de tela 2024-05-28 165526](https://europe1.discourse-cdn.com/n8n/original/3X/0/9/091aa2953390d5ecc71d1f70c490508598862af7.png)

{  
“meta”: {  
“templateCredsSetupCompleted”: true,  
“instanceId”: “8f15dc730c58cd2eb5917ce235e3dee955c5e1e6d48924c721d3be25bba46505”  
},  
“nodes”: [  
{  
“parameters”: {  
“method”: “POST”,  
“url”: “[https://crm.rdstation.com/api/v1/tasks?token=66534df919eb1d0012fec498](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”: {}  
}

 ![Captura de tela 2024-05-28 163207](https://europe1.discourse-cdn.com/n8n/original/3X/9/1/91835fc1d55c0a43eda0960927c34b5bcde4a711.png)  
 ![Captura de tela 2024-05-28 155531](https://europe1.discourse-cdn.com/n8n/original/3X/5/8/5890e4ec019cc8d4ce373dc84549f48dd3e8efe1.png)

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [May 28, 2024, 8:18pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/2 "2024-05-28T20:18:28Z")

</div>

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:**

---

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.n8n.io/u/mateus.silva)\
**Post date:** [May 28, 2024, 8:32pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/3 "2024-05-28T20:32:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [May 29, 2024, 6:03am UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/4 "2024-05-29T06:03:55Z")

</div>

@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

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

```

---

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.n8n.io/u/mateus.silva)\
**Post date:** [May 29, 2024, 12:20pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/5 "2024-05-29T12:20:30Z")

</div>

![image](https://europe1.discourse-cdn.com/n8n/original/3X/e/e/eea595925191861ccbb02ce5c305c02c26a16aa2.png)  
Thus?

I did not work 😕

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

```

---

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.n8n.io/u/mateus.silva)\
**Post date:** [May 29, 2024, 12:24pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/6 "2024-05-29T12:24:16Z")

</div>

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

```auto
PiOqX1TwqMZuibMc

```

[type or paste code here](http://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/5)

```auto

```

---

<div class="post-metadata">

**Author:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [May 29, 2024, 3:12pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/7 "2024-05-29T15:12:22Z")

</div>

@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

```auto
{{
  YOUR JSON GOES HERE
}}

```

---

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.n8n.io/u/mateus.silva)\
**Post date:** [May 29, 2024, 5:35pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/8 "2024-05-29T17:35:47Z")

</div>

@ihortom unsuccessfully.

 ![Captura de tela 2024-05-29 143236](https://europe1.discourse-cdn.com/n8n/original/3X/1/c/1c202b5f9528c50478b47251b55bc4e0a7825fc3.png)

{ {  
{  
“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  
}  
}  
}}

---

<div class="post-metadata">

**Author:** ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.n8n.io/u/mateus.silva)\
**Post date:** [May 29, 2024, 5:44pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/10 "2024-05-29T17:44:40Z")

</div>



---

<div class="post-metadata">

**Author:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [May 29, 2024, 10:28pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/11 "2024-05-29T22:28:26Z")

</div>

@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.

```auto
{ { // 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 }}

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [August 27, 2024, 10:29pm UTC](https://community.n8n.io/t/problem-with-an-http-request-json-parameter-need-to-be-a-valid-json-in-variables/47340/12 "2024-08-27T22:29:20Z")

</div>

Closed on August 27, 2024, 10:29pm UTC

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