Hi guys!
First of all, thanks a lot for the code. I’ve tested it with postman and it delivers exactly what I wanted.
I’m having an issue with the webhooks node.
Below is the exact code I’m using in google apps script (just changed the form ID):
function onFormSubmit(e) {
const url = "http://n8n.navarratrader.com/webhook-test/webhook_chase"; //n8n WebHook URL
// get our form details
const form = FormApp.openById("XXXXXXXXXXXXXXXXXXX"); // Copy the Form ID from the URL
const formResponses = form.getResponses();
const fields = form.getItems()
const fieldNames = fields.map((item) => item.getTitle())
// list of field name like ["title", "message", "name", etc]
console.log('fieldnames ->', { fieldNames })
// now, fetch the latest submission
const formResponse = formResponses[formResponses.length - 1];
const itemResponses = formResponse.getItemResponses();
const formSubmission = itemResponses.map((field) => field.getResponse())
// build our payload to send to n8n
let index = 0
let payload = {}
for (const field of fieldNames) {
payload[field] = formSubmission[index]
index++
}
console.log('formsubmission ->', { formSubmission })
console.log('payload ->', { payload })
// finally send along our request as a POST request to the n8n endpoint
const options = {
method: "POST",
headers: {
'Accept': 'application/json',
"Content-Type": "application/json"
},
payload: JSON.stringify(payload),
};
const response = UrlFetchApp.fetch(url, options);
Logger.log(JSON.stringify(response));
//UrlFetchApp.fetch(url, options).then(res => res.JSON)
//.then(response => console.log('res yo', JSON.stringify(response)))
//.catch(err => console.log('fucking error!!!', err))
}
This is my workflow:
As you can see, my code uses POST. In the workflow I have inserted both a GET webhook and a POST webhook. Not sure why, but only the GET works.
When I disable the GET webhook node and try to use only the POST webhook node, I get the following error:
Exception: Request failed for http://n8n.navarratrader.com returned code 404. Truncated server response: {“code”:404,“message”:“This webhook is not registered for GET requests. Did you mean to make a POST request?”,“hint”:"Click the ‘Execute workflow’ … (use muteHttpExceptions option to examine full response)
I am currently running tests with the test link (workflow disabled), but I have also tried with the production link (workflow enabled) and still only the GET worked. (image below)
The main issue with the GET call is that is comes without the payload, so I can’t use the data.
I’m running an auto-hosted docker n8n on ubuntu.
My version is 0.237.0
I’m sure I’m missing something, but by myself have been unable to figure it out.
Any ideas?