Skip to content

Instantly share code, notes, and snippets.

@ibek
Last active March 27, 2017 16:55
Show Gist options
  • Save ibek/22f0c7c655bf31b06f728ce1fe0df7ad to your computer and use it in GitHub Desktop.
Save ibek/22f0c7c655bf31b06f728ce1fe0df7ad to your computer and use it in GitHub Desktop.
Google Forms Apps Script to do REST request
function startProcess(e) {
var formResponse = e.response;
var itemResponses = formResponse.getItemResponses();
var data = {};
for (var j = 0; j < itemResponses.length; j++) {
var itemResponse = itemResponses[j];
var title = itemResponse.getItem().getTitle();
data[title] = itemResponse.getResponse();
}
var options = {
'method' : 'post',
'contentType': 'application/json',
// Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify(data)
};
// start a process instance on KIE Server
UrlFetchApp.fetch('https://httpbin.org/post', options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment