Skip to content

Instantly share code, notes, and snippets.

@5un
Last active February 19, 2023 00:07
Show Gist options
  • Save 5un/02c7906429274d73a6657f36f769a8be to your computer and use it in GitHub Desktop.
Save 5un/02c7906429274d73a6657f36f769a8be to your computer and use it in GitHub Desktop.
post-google-forms-nodejs
var request = require('superagent');
// https://docs.google.com/forms/d/<form-id>/edit
var formId = 'YOUR_FORM_ID';
var fields = {
size: 'entry.1721541334',
sizeOther: 'entry.1721541334.other_option_response',
email: 'entry.1414359800',
mobile: 'entry.1534391001',
delivery_method: 'entry.1215248009',
address: 'entry.1445466410'
}
request
.post(`https://docs.google.com/forms/d/e/${formId}/formResponse`)
.type('form')
.send({
[fields.size]: 'M',
[fields.sizeOther]: 'SS',
[fields.email]: '[email protected]',
[fields.delivery_method]: 'post',
[fields.mobile]: '0811111111',
[fields.address]: '66 Test Street Bangkok'
})
.end(function(err, res){
if (err || !res.ok) {
console.error(err);
} else {
console.log(res.body);
}
});
@MontoyaAndres
Copy link

Thank you so much! This helps a lot!

@Permpol
Copy link

Permpol commented Jan 26, 2022

How to fix in case of being forced to log in before posting?

@snowfluke
Copy link

snowfluke commented Mar 22, 2022

How to login for a form that requires login?

It needs a "token" properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment