Hi everyone,
Before anything else: I am not a coder. I am just a small business owner that’s using n8n for the first time and setting stuff up with youtube and chatgpt’s help. So, if I say something inappropriate or stupid, please correct me and I will try my best not to do it again.
Here’s my problem:
I have a contact form on my website, that sends the webhook the following data:
[
{
"headers": {
"host": "n8n.xyz.net",
"user-agent": "WordPress/6.6.2; https://abc.com",
"content-length": "581",
"accept": "*/*",
"accept-encoding": "gzip, br",
"cdn-loop": "cloudflare; loops=1",
"cf-connecting-ip": "2a02:4780:11:1226:0:e95:9dd7:xxxx",
"cf-ipcountry": "IN",
"cf-ray": "8dad3ebd4cc13bb0-BOM",
"cf-visitor": "{\"scheme\":\"https\"}",
"cf-warp-tag-id": "c473a44d-5f33-48d5-809f-a44afc14eaa2",
"connection": "keep-alive",
"content-type": "application/x-www-form-urlencoded",
"x-forwarded-for": "2a02:4780:11:1226:0:e95:9dd7:xxxx",
"x-forwarded-proto": "https"
},
"params": {},
"query": {},
"body": {
"entries": "{\"iei-contact-form-first-name\":\"testing3\",\"iei-contact-form-last-name\":\"contact\",\"iei-contact-form-email-address\":\"[email protected]\",\"iei-contact-form-phone\":\"+919191919191\",\"iei-contact-form-customer-type\":\"founder\",\"iei-contact-form-location\":\"\",\"iei-contact-form-subject-line\":\"fdsfgsdf\",\"iei-contact-form-message\":\"fdsfs\"}",
"entry_id": "6730",
"form_id": "766",
"version": "3.9.0",
"file_uploads": "null",
"referrer_url": "https://abc.com/contact-us/?v=6470f4a3ad01"
},
"webhookUrl": "https://n8n.xyz.net/webhook-test/efe9acba-0893-41fd-af24-34a73eb97067",
"executionMode": "test"
}
]
which I passed to “Set” module (because I saw a post here saying that’s what should be used) and I get the output:
[
{
"iei-contact-form-first-name": "testing2",
"iei-contact-form-last-name": "contact",
"iei-contact-form-email-address": "[email protected]",
"iei-contact-form-phone": "+919191919191",
"iei-contact-form-customer-type": "founder",
"iei-contact-form-location": "",
"iei-contact-form-subject-line": "fdsfgsdf",
"iei-contact-form-message": "hfdgdg"
}
]
which I pass to an HTTP Request to call my CRM’s API. If I hard-code the values, it works, so I know there’s no errors in calling it.
this is the body text I pass to the API call:
{
"query": "mutation createOrUpdateContact($input: CreateContactInput!) { createContact(input: $input) { id } }",
"variables": {
"input": {
"email": {{ $json["iei-contact-form-email-address"] }} ,
"firstName": {{ $json["iei-contact-form-first-name"] }},
"lastName": {{ $json["iei-contact-form-last-name"] }},
"audienceId": "10717405865239368",
"profile": [
{
"dataFieldId": "10373567253869411",
"value": {{ $json["iei-contact-form-phone"] }}
}
],
"groupIds": [],
"updateExisting": true
}
}
}
but I get this error:
{
"errorMessage": "JSON parameter needs to be valid JSON",
"errorDetails": {},
"n8nDetails": {
"nodeName": "HTTP Request",
"nodeType": "n8n-nodes-base.httpRequest",
"nodeVersion": 4.2,
"itemIndex": 0,
"time": "10/30/2024, 11:58:49 PM",
"n8nVersion": "1.64.3 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"NodeOperationError: JSON parameter needs to be valid JSON",
" at Object.execute (/home/pi/.nodejs_global/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts:341:14)",
" at Workflow.runNode (/home/pi/.nodejs_global/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1382:31)",
" at /home/pi/.nodejs_global/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:1167:42",
" at /home/pi/.nodejs_global/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:1887:11"
]
}
}
I used the expression thingie and dragged/dropped the values from the input.
I checked the docs and it said something about JMESPath, and when I used that, all the outputs come out as “undefined”.
Please help.