Hey folks,
I’m completely stumped and hope someone here can see what I’m missing.
Describe the problem/error/question
I have two almost-identical bodies of HTTP requests that should build the same JSON payload for an external API (nocodb):
Dynamic version (crashes):
{
“title”: “{{ $(‘return’).item.json.title }}”,
“fields”: {{ $json.columns }} // or .toJsonString(), tried both
}
Manual version (works):
{
“title”: “{{ $(‘return’).item.json.title }}”,
“fields”: [
{ “title”: “propertyId”, “type”: “SingleLineText” },
{ “title”: “internalId”, “type”: “SingleLineText” },
{ “title”: “name”, “type”: “SingleLineText” },
{ “title”: “note”, “type”: “SingleLineText” },
{ “title”: “country”, “type”: “SingleLineText” },
{ “title”: “city”, “type”: “SingleLineText” },
{ “title”: “postalCode”, “type”: “SingleLineText” },
{ “title”: “number”, “type”: “SingleLineText” },
{ “title”: “mscNumber”, “type”: “SingleLineText” },
{ “title”: “mscProviderName”, “type”: “SingleLineText” },
{ “title”: “mscProviderIdentifier”, “type”: “SingleLineText” },
{ “title”: “addresses”, “type”: “JSON” },
{ “title”: “responsibilities”, “type”: “JSON” },
{ “title”: “appLink”, “type”: “SingleLineText” },
{ “title”: “images”, “type”: “JSON” },
{ “title”: “customFields”, “type”: “JSON” }
]
}
* `$json.columns` **is literally the same array** that I copy from the n8n preview.
* When I paste that preview by hand into the “manual” request, the API says **200 OK**.
If I use it dynamically it crashes. There should be zero difference between them
{
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-64,
1920
],
"id": "1063f4c4-6a05-4530-b016-9dbd7e6abcb2",
"name": "Schedule Trigger2"
},
{
"parameters": {
"url": "=https://nocodb.klaeffling-n8n.de/api/v3/meta/bases/{{ $json.list[0].sources[0].base_id }}/tables",
"options": {},
"headerParametersUi": {
"parameter": [
{
"name": "xc-token",
"value": "="
}
]
}
},
"id": "fff2c61e-3139-43d4-aec7-d73942c54060",
"name": "Get tables2",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
544,
1920
]
},
{
"parameters": {
"url": "=https://nocodb.klaeffling-n8n.de/api/v3/meta/bases/{{ $('Get base kläffling1').item.json.list[0].sources[0].base_id }}/tables/{{ $json.id }}",
"options": {},
"headerParametersUi": {
"parameter": [
{
"name": "xc-token",
"value": "=string"
}
]
}
},
"id": "ff521451-c54c-4b6c-af96-a0c933223618",
"name": "Get tables3",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
912,
1920
]
},
{
"parameters": {
"fieldToSplitOut": "list",
"options": {}
},
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [
720,
1920
],
"id": "54ccc6e1-3d68-4c45-823c-274dd01ca095",
"name": "Split Out1"
},
{
"parameters": {
"url": "https://nocodb.klaeffling-n8n.de/api/v2/meta/bases",
"options": {},
"headerParametersUi": {
"parameter": [
{
"name": "xc-token",
"value": "=string"
}
]
}
},
"id": "ca637aa8-a306-4a53-84f5-af48e6a48bd4",
"name": "Get base kläffling1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
336,
1920
]
},
{
"parameters": {},
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
144,
2144
],
"id": "a2ace7e1-44f5-4ea9-b29f-d8f5887edaec",
"name": "Erstellen1"
},
{
"parameters": {},
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
144,
1920
],
"id": "8089ce08-2145-435f-875c-8b82d57d538a",
"name": "Base Daten abholen1"
},
{
"parameters": {
"requestMethod": "POST",
"url": "=https://nocodb.sonntag-verwaltung-n8n.de/api/v3/meta/workspaces/pu87vftht2vbjib/bases",
"options": {},
"bodyParametersUi": {
"parameter": [
{
"name": "title",
"value": "pmc-001-nocodbSync-casavi"
}
]
},
"headerParametersUi": {
"parameter": [
{
"name": "xc-token",
"value": "string"
}
]
}
},
"id": "93214991-6b79-490f-a2b0-778a63f78aba",
"name": "create base - workspace id einfügen1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
336,
2144
],
"executeOnce": true,
"disabled": true
},
{
"parameters": {
"jsCode": "\nreturn $items(\"Get tables3\")"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
544,
2144
],
"id": "189c5347-4453-46ec-b2b3-5a7275a3965b",
"name": "return1"
},
{
"parameters": {
"jsCode": "return items.map(({ json }) => ({\n json: {\n title: json.title,\n columns: (json.fields ?? [])\n .filter(({ title }) => title.toLowerCase() !== 'id')\n .map(({ title, type }) => ({ title, type })),\n },\n}));\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
752,
2144
],
"id": "901ebffd-565b-4a44-ba35-3c12b70aa9a5",
"name": "Code2"
},
{
"parameters": {
"method": "POST",
"url": "=https://nocodb.sonntag-verwaltung-n8n.de/api/v3/meta/bases/p50klk1at0pzysp/tables",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "xc-token",
"value": "string"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"title\": \"{{ $('return1').item.json.title }}\",\n \"fields\": \n{{ $json.columns.toJsonString() }}\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
976,
2144
],
"id": "fa92da92-29a8-45d1-9d5d-5206d557530d",
"name": "HTTP Request1"
}
],
"connections": {
"Schedule Trigger2": {
"main": [
[
{
"node": "Base Daten abholen1",
"type": "main",
"index": 0
}
]
]
},
"Get tables2": {
"main": [
[
{
"node": "Split Out1",
"type": "main",
"index": 0
}
]
]
},
"Get tables3": {
"main": [
[
{
"node": "Erstellen1",
"type": "main",
"index": 0
}
]
]
},
"Split Out1": {
"main": [
[
{
"node": "Get tables3",
"type": "main",
"index": 0
}
]
]
},
"Get base kläffling1": {
"main": [
[
{
"node": "Get tables2",
"type": "main",
"index": 0
}
]
]
},
"Erstellen1": {
"main": [
[
{
"node": "create base - workspace id einfügen1",
"type": "main",
"index": 0
}
]
]
},
"Base Daten abholen1": {
"main": [
[
{
"node": "Get base kläffling1",
"type": "main",
"index": 0
}
]
]
},
"create base - workspace id einfügen1": {
"main": [
[
{
"node": "return1",
"type": "main",
"index": 0
}
]
]
},
"return1": {
"main": [
[
{
"node": "Code2",
"type": "main",
"index": 0
}
]
]
},
"Code2": {
"main": [
[
{
"node": "HTTP Request1",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "eb9e9e30c84eb5d9c09fcc0d5b13e4c2738e25c19d23f8858d7d97915e5ad081"
}
}
Update - I was also able to reproduce this in much simpler circumstances. I did a http request while manually setting the URL. Then I did the http request again but this time, part of the URL was dynamic (from an earlier set-node) --> suddenly the the API just randomly says "cannot POST etc etc"
Then I go back and use the manual version again, where the URL was not dynamic and suddenly its working again. Even though there is NO change whatsoever. Just from going from dynamic back to static.
# Error Message
422 - "{\"error\":\"DATABASE_ERROR\",\"message\":\"A value is required for this field.\",\"code\":\"23502\"}"
## Information on your n8n setup
- **n8n version:** newest
- **Operating system:** Ubuntu