Subject: Issues Sending Dynamic JSON to Notion from n8n - "Unexpected Token" Error

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:

  1. Static Version of the JSON: If I replace the dynamic values with fixed values, the JSON seems to work fine.
  2. Simplified JSON: I removed fields like "type": "database_id" and "icon" to ensure the structure is correct.
  3. 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:

  1. Why is the JSON with dynamic placeholders ({{$json[...]}}) failing?: Is it possible that n8n is sending the placeholders without evaluating them properly?
  2. Are there any restrictions or specific configurations needed to send dynamic values using the HTTP Request node?
  3. 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.

1 Like

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:

FWIW n8n version here is important to share—I was getting a ton of errors due to updates in Notion’s page ID structure a few weeks back. All of my Notion API calls were throwing errors.

Which version of n8n are you running?

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