JSON parameter need to be an valid JSON with Value from previous node

Hey there, I did see that there are serveral posts about that Error.

using self hosted 1.33.1

What I found out is if I remove the {{ $json.ITEMS }} or replace it with the created code it does work. So the issue comes from that. But so far I couldn’t find why.

In the result of Item 1 it looks all correct

Also when I copy the full Result and put it into the expression it works as well.

Does any know what could be wrong?

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:

Can you share the whole workflow?

Often this happens when there are separate branches in the workflow. Not a bug, it’s what the merge node is for. There are also some other ways around it.

if you can send the full workflow i’ll take a look

Hi Liam, thank you for your help again.

this is the part you need I guess

The strange thing is really that if I remove the Items it works and also If I hardcode the result into the JSON

I’m a little confused still. I’m not sure what/where the issue is.

Which node is this happening?
And what is happening? The json isn’t being recognized? Can you send a screenshot of the actual error message

it is in the last module

if I remove the {{ $json.ITEMS }} it works. But when I use the Expression result and copy into the JSON part then it works as well. Is seems only not to work when the Items get created dynamically

please send a sample of the json from ITEMS so that i can do some testing

Please also expand the error details in that screenshot, usually that gives more info

This is the ITEMS output

[
{
“ITEMS”: [
{
“DESCRIPTION”: “snapADDY”,
“UNIT_PRICE”: 120,
“VAT_PERCENT”: 19,
“QUANTITY”: 1,
“SORT_ORDER”: 0
},
{
“DESCRIPTION”: “sevDesk Beratung”,
“UNIT_PRICE”: 160,
“VAT_PERCENT”: 22,
“QUANTITY”: 1,
“SORT_ORDER”: 1
}
]
}
]

and Error

{
“errorMessage”: “JSON parameter need to be an valid JSON”,
“errorDetails”: {},
“n8nDetails”: {
“nodeName”: “Fastbill - Invoice create”,
“nodeType”: “n8n-nodes-base.httpRequest”,
“nodeVersion”: 4.1,
“itemIndex”: 0,
“time”: “1.5.2024, 15:58:50”,
“n8nVersion”: “1.33.1 (Self Hosted)”,
“binaryDataMode”: “default”,
“stackTrace”: [
“NodeOperationError: JSON parameter need to be an valid JSON”,
" at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1301:35)“,
" at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:724:19)”,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:660:53",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1062:20"
]
}
}

Hey Liam, did you find any solution for that?

In the last node try replacing this:

"ITEM":[
{{ $json.ITEMS }}
]

with this

"ITEM":[
{{ $json.ITEMS.map(item => JSON.stringify(item)).join(', ') }}
]

If you look at the preview you currently have you can see the json it is creating isn’t valid

Let me know if that works for you

Sorry for the delay, haven’t had any time to spare

2 Likes

Thank you @liam you are great :slight_smile:

This little line fixed it!

For sure no sorry for the “delay” :smiling_face: I’m very happy that you always help and find time for that. You have my Thanks!

2 Likes

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