Error using SET node

I’m using a process to update a Google Spreadsheet, but when assigning the value in SET, it’s showing an error.

What is the error message (if any)?

ERROR: Unexpected token u in JSON at position 0

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.execute (/usr/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Set/Set.node.js:142:37)
    at Workflow.runNode (/usr/lib/node_modules/n8n/node_modules/n8n-workflow/dist/src/Workflow.js:598:51)
    at /usr/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:557:68
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Please share the workflow

stretch of workflow

Hi @alehsoares, welcome to the community!

I am sorry to hear you’re having trouble. Could you share the JSON data returned by your Webhook node (you can redact the values themselves, it’s just the data structure I am curious about) as well as the JSON data coming from your HTTP Request node so I can reproduce this on my side?

Also, can you confirm which version of n8n exactly you are using?

Hi @MutedJam ,

i have the same problem on a workflow, where the prev node will return 1 item, but with no output data.


and on the set Node, i will get the json error.
image

n8n Version 0.190.0

Hi @ChristianV, could you please provide the JSON payload you’re using in your Set node along with the node (simply hit Ctrl+C after selecting it) so I can reproduce the problem? Feel free to redact the actual values, it’s just the structure I’d like to understand. Thx!

@MutedJam

This is the .json Output from Check Stage

[
{
"project_id": [
{
"id": 116,
"name": "Service- New"
}
],
"stage_id": [
{
"id": 220,
"name": "customer create"
}
],
"name": "S23845: Product A",
"sale_order_id": [
{
"id": 68101,
"name": "S23845"
}
],
"partner_id": [
{
"id": 4810,
"name": "Max Mustermann"
}
],
"id": 4623
}
]

Hi @ChristianV, many thanks!

I gave this a go on my end by building the below workflow resembling yours as closely as possible using the information you have provided:

The Set node is, however, executed as expected:

Could you can provide a self-sufficient workflow including static data (rather then relying on external data sources providing a specific response) using which your problem can be reproduced (similar to the one I have posted here)?

Thanks so much!

@MutedJam the problem is, i can only see the error in “Workflow Executions”, cause this workflow is triggered by webhook, if i run the workflow manually, i have newer the problem, also on webhook-test it runs without any error.
also as information, this happened 1/10 executions and by this Error-one, if re-run it manually, it will work.

Thanks @ChristianV. I tried running my test workflow with an added webhook in production mode, but it still finished fine for me:

So it’d be super helpful if you could provide a workflow using which this problem can be reproduced outside of your environment.

Ok.

This is my Webhook JSON:

[
  {
    "headers": {
      "content-type": "application/json",
      "host": "localhost:5678",
      "accept": "application/json",
      "content-length": "1268",
      "connection": "close"
    },
    "params": {},
    "query": {},
    "body": {
      "_data": {
        "id": {
          "fromMe": false,
          "remote": "[email protected]",
          "id": "XXXXXXXXXXX",
          "_serialized": "[email protected]_XXXXXXXXXXX"
        },
        "body": "Oi",
        "type": "chat",
        "t": XXXXXXXXXXX,
        "notifyName": "XXXXXXXXXXX",
        "from": "[email protected]",
        "to": "[email protected]",
        "self": "in",
        "ack": 1,
        "isNewMsg": true,
        "star": false,
        "kicNotified": false,
        "recvFresh": true,
        "isFromTemplate": false,
        "pollInvalidated": false,
        "broadcast": false,
        "mentionedJidList": [],
        "isVcardOverMmsDocument": false,
        "isForwarded": false,
        "hasReaction": false,
        "ephemeralOutOfSync": false,
        "productHeaderImageRejected": false,
        "lastPlaybackProgress": 0,
        "isDynamicReplyButtonsMsg": false,
        "isMdHistoryMsg": false,
        "requiresDirectConnection": false,
        "pttForwardedFeaturesEnabled": true,
        "isEphemeral": false,
        "isStatusV3": false,
        "links": []
      },
      "id": {
        "fromMe": false,
        "remote": "[email protected]",
        "id": "XXXXXXXXXXX",
        "_serialized": "[email protected]_XXXXXXXXXXX"
      },
      "ack": 1,
      "hasMedia": false,
      "body": "Oi",
      "type": "chat",
      "timestamp": 99999999,
      "from": "[email protected]",
      "to": "[email protected]",
      "deviceType": "web",
      "isForwarded": false,
      "forwardingScore": 0,
      "isStatus": false,
      "isStarred": false,
      "broadcast": false,
      "fromMe": false,
      "hasQuotedMsg": false,
      "vCards": [],
      "mentionedIds": [],
      "isGif": false,
      "isEphemeral": false,
      "links": []
    }
  }
]

HTTP Request JSON:

{"number":"{{$node["Webhook"].json["body"]["_data"]["from"]}}","message":"*Olá {{$node["Webhook"].json["body"]["_data"]["notifyName"]}}, tudo bem?*\n\n_Escolha uma das opções abaixo:_\n\n1-Financeiro\n2-Comercial\n3-Jurídico\n0-Voltar ao início","ticketwhatsappId":1,"token":"XXXXXXXXXXXXXXXXXXX"}

N8N version: 0.191.0

Hey @alehsoares, I tried reproducing your problem using the below workflow

I was sending the below request:

curl --request POST \
  --url http://localhost:5678/webhook-test/cf856a9f-df9e-420d-870f-eae0a861ca04 \
  --header 'Content-Type: application/json' \
  --data '{
	"_data": {
		"id": {
			"fromMe": false,
			"remote": "[email protected]",
			"id": "XXXXXXXXXXX",
			"_serialized": "[email protected]_XXXXXXXXXXX"
		},
		"body": "Oi",
		"type": "chat",
		"t": "XXXXXXXXXXX",
		"notifyName": "XXXXXXXXXXX",
		"from": "[email protected]",
		"to": "[email protected]",
		"self": "in",
		"ack": 1,
		"isNewMsg": true,
		"star": false,
		"kicNotified": false,
		"recvFresh": true,
		"isFromTemplate": false,
		"pollInvalidated": false,
		"broadcast": false,
		"mentionedJidList": [],
		"isVcardOverMmsDocument": false,
		"isForwarded": false,
		"hasReaction": false,
		"ephemeralOutOfSync": false,
		"productHeaderImageRejected": false,
		"lastPlaybackProgress": 0,
		"isDynamicReplyButtonsMsg": false,
		"isMdHistoryMsg": false,
		"requiresDirectConnection": false,
		"pttForwardedFeaturesEnabled": true,
		"isEphemeral": false,
		"isStatusV3": false,
		"links": []
	},
	"id": {
		"fromMe": false,
		"remote": "[email protected]",
		"id": "XXXXXXXXXXX",
		"_serialized": "[email protected]_XXXXXXXXXXX"
	},
	"ack": 1,
	"hasMedia": false,
	"body": "Oi",
	"type": "chat",
	"timestamp": 99999999,
	"from": "[email protected]",
	"to": "[email protected]",
	"deviceType": "web",
	"isForwarded": false,
	"forwardingScore": 0,
	"isStatus": false,
	"isStarred": false,
	"broadcast": false,
	"fromMe": false,
	"hasQuotedMsg": false,
	"vCards": [],
	"mentionedIds": [],
	"isGif": false,
	"isEphemeral": false,
	"links": []
}'

However, both the HTTP Request as well as the Set node executed fine for me:

So unfortunately I am still not able to reproduce the problem on my end. Perhaps you can share an example workflow I am able to run on my side using which your problem can be reproduced?

Can I send you the complete workflow without attaching it here in the message? Because it has credentials and some personal data.