Hi, I’m updating notion from Airtable.
I’m using the HTTP request node as I need to update relation field.
It works well except when multiple relations are involved. I’m having a “ERROR: JSON parameter need to be an valid JSON” error with the following javacript:
“Companies”: {
“relation”: [
{{ $json[“fields”][“NotionId (from Firm)”].map(id => ({ “id”: id })) }}]
}
But the “rendering” looks just fine:
“Companies”: {
“relation”: [
{“id”: “1deb6df5-4c34-49bd-84b0-8d8e289f5327”},{“id”: “0e1813cc-7b24-4a9e-b5cb-2e4953778f89”}]
}
And by the way when I replace the javascript with a static text it works.
Would definitely use some help here. Thank you
Here is the full JSON body:
{
"properties": {
"Name": {
"title": [
{
"text": {
"content": "{{$json.fields.Name}}"
}
}
]
},
"Notes": {
"rich_text": [
{
"type": "text",
"text": {
"content": "{{$json.fields.Notes.replace(/[\r\n"]+/g, "")}}"
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
}
}
]
},
"Companies": {
"relation": [
{{ $json["fields"]["NotionId (from Firm)"].map(id => ({ "id": id })) }}]
}
}
}
Information on your n8n setup
- n8n version: 1.32.2
- Database (default: SQLite): SQLite
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker