Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Forms + Webhook : JSON example
function onFormSubmit(e) {
var data = {
"form": {
"id": e.source.getId(),
"title": e.source.getTitle() ? e.source.getTitle() : "Untitled Form",
"is_private": e.source.requiresLogin(),
"is_published": e.source.isAcceptingResponses(),
"response": {
"id": e.response.getId(),
"timestamp": e.response.getTimestamp(),
"payload": e.response.getItemResponses().map(function(y) {
return {
h: y.getItem().getTitle(),
k: y.getResponse()
}, this).reduce(function(r, y) {
r[y.h] = y.k;
return r
}, {});
var options = {
method: "post",
payload: JSON.stringify(data, null, 2),
contentType: "application/json; charset=utf-8",
UrlFetchApp.fetch("", options);

This comment has been minimized.

Copy link

@chunlaw chunlaw commented Jul 8, 2018

Line 20 should be a comma instead of a semicolon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.