Hi,
I’m facing a persistent issue when trying to send dynamic JSON data to the Notion API using n8n, and I would appreciate your help in identifying what might be going wrong and how to solve it.
Problem Description
I am using an HTTP Request node in n8n to create a new page in Notion. I’m constructing the JSON that Notion expects, using dynamic values for certain fields. Here is the JSON I am trying to send:
json
Copiar código
{
"parent": {
"database_id": "d6036f471ea8495e96c7d82a935abb95"
},
"icon": {
"type": "external",
"external": {
"url": "https://upload.wikimedia.org/wikipedia/commons/4/42/YouTube_icon_%282013-2017%29.png"
}
},
"properties": {
"Nombre": {
"title": [
{
"text": {
"content": "{{$json['Nombre']}}"
}
}
]
},
"Autor": {
"multi_select": [
{
"name": "{{$json['Autor']}}"
}
]
},
"Estado": {
"select": {
"name": "Sin empezar"
}
},
"Tipo": {
"select": {
"name": "YouTube"
}
},
"URL": {
"url": "{{$json['URL']}}"
}
}
}
Specific Problem
When I attempt to send this JSON, I keep getting the error “Unexpected Token [line 2]”, which makes me think there’s a problem in the way n8n is processing the dynamic placeholders ({{$json[...]}}
).
Here are some of the options I have already tried:
- Static Version of the JSON: If I replace the dynamic values with fixed values, the JSON seems to work fine.
- Simplified JSON: I removed fields like
"type": "database_id"
and"icon"
to ensure the structure is correct. - Online Validation: I have validated the JSON using tools like jsonlint.com, and it seems to be correct.
Questions and Request for Assistance
I would like to understand:
- Why is the JSON with dynamic placeholders (
{{$json[...]}}
) failing?: Is it possible that n8n is sending the placeholders without evaluating them properly? - Are there any restrictions or specific configurations needed to send dynamic values using the HTTP Request node?
- What should I modify to ensure that the dynamic values are properly evaluated before the JSON is sent to Notion?
I would greatly appreciate any guidance or suggestions on how to resolve this issue. I am trying to automate a process that depends on dynamic data, and this limitation is preventing me from moving forward.
Thank you in advance for your help.
Best regards,
Rodrigo Herrera S.