How to submit a Google Form response using a Webhook

  • 22 October 2021
  • 6 replies
  • 1801 views

Userlevel 7
Badge +11
  • Community Manager
  • 5453 replies

Hey friends! Want to have a Zap submit Google Form responses? And have those responses appear in the list of form responses in Google Forms, as well as in the connected Google Sheet?

Well, I have good news for you! After some digging through Google’s API docs, I figured out a way to do that using a Webhook action. You’re welcome ;-)

Requirements

In order to set up the webhook we simply need to know two things:

  1. The URL for your Google Form

  2. The IDs for your Google Form fields 

Don’t know how to find that info? No worries, we’ll be covering that next...

How to get the URL for your form

In Google Forms, click on the eye icon to preview your form:

43dc8492f6fc57fd8088f8b9a193165d.png
 

This will open the form in a new tab. In the address bar you’ll see the URL for your form:

a65c81ba97edab8ae930c66474ac1460.png
 

How to get the IDs for each form field

A easy way to get the field ID is to use the pre-filled link option. To get the pre-filled link, when editing your Google Form click the 3 dots icon on the top right of the screen and select Get pre-filled link:

1ab79dbd85cc9c1c0bb45980be13f8f5.png

This will open a new tab with a preview of the form. Here you’ll need to fill out all of the fields in the form so that they have a value. Then click the Get Link button.

At the bottom of the screen a message will appear with a link that says COPY LINK - click that to get the pre-filled link copied to your clipboard.

5d85a918b417a81c862fc48926c6efcd.png
 

Here’s an example of how that pre-filed link would look:

https://docs.google.com/forms/d/e/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/viewform?usp=pp_url&entry.39984557=Clark+Kent&entry.312118451=DC!&entry.604818352=Superman

In the example above, I’ve highlighted the IDs of each field in bold. These are followed by the value that was entered for each field. 

Setting up the Webhook

In the Zap that you want to have submitting the form, add a Webhooks by Zapier step and select the POST action event.

1c8c72aeebd6b7a589ce85ff95b73808.png

For the URL we’ll want to take the form URL we found earlier and replace the viewform text that appears at the end of it, with formResponse instead. The new URL will look something like this: 

7a6ca7ec21ac5f3a16c69d1623493589.png

Next, make sure the Payload Type has been set to form:

e8343be347fdf9f372afb363948b0e72.png
 

Then in the Data section you’ll want to start copying over the IDs for the fields from that pre-filled link. The IDs should go on the left and the values to be added to those fields should go on the right:

353b0ba850fdacfc28cfc6162104e75f.png
 

For fields with predetermined options to choose from (like checkboxes), make sure the values you’re sending exactly match the available options or you’ll run into a Bad Request error. 

Finally, you’ll need to add a Content Type header with a value of application/x-www-form-urlencoded:

db51752ac9d5faf4f3a9c275a3d726da.png
 

Next, you’re ready to test your Zap. From the Test Action screen, click the Test & Review button to submit the response. That should then add the test form response into both Google Forms and Google Sheets:

1ae79ced279cb292e71c1495fb06e7bf.png

And that’s it. I hope you find this workaround useful! :)


6 replies

I love this! Thank you!

 

I’m having a bit an issue with the authentication. 

“The app returned "Unauthorized".”

 

do I need to add an API key or something?

 

Userlevel 7
Badge +11

Hey @cvelez, welcome to the Community! :slight_smile:

Hmm, it shouldn’t be necessary to provide authorisation. That said, I’ve seen that “Unauthorized” error in the past when a Google Form had permissions set so that only users in the form owner’s organisation could view it. If that’s the case here, can you try adjusting the permissions for the form in Google directly to see if you’re then able to successfully submit the webhook without error?

I don't understand the point. What would be a use case for having a form filled out? Why is this form being filled out this data being taken from someone and put into the form? Doesn't Google forms already create a spreadsheet once the form has been submitted? 

This is exactly what I am looking for. Unfortunately, getting the following error:

 

Failed to create a request in Webhooks by Zapier
Page Not Found

 

I also tried changing the url slightly based on an actual form submission url from chromes devtools/network but getting the same error:

https://docs.google.com/forms/u/0/d/e/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX/formResponse

 

Thanks in advance for any ideas on what to try.

Userlevel 1

Just wanted to say THANK YOU, IT WORKED, and your guide ROCKS!

Userlevel 7
Badge +11

Hey folks! 👋

I’m so sorry we missed your messages here previously @thecupisonthefloor and @BlueDolphin

@thecupisonthefloor

I don't understand the point. What would be a use case for having a form filled out? Why is this form being filled out this data being taken from someone and put into the form? Doesn't Google forms already create a spreadsheet once the form has been submitted?

Yes that’s correct. But in some cases folks may want to take information captured by another app and use it to submit the form so that the form response is displayed in the list of form responses within Google Forms, as well as added to the connected Google Sheets spreadsheet as well. The Google Forms app on Zapier doesn’t currently have a “Create Form Response” type of action so the above guide offers a workaround for that. 

 

@BlueDolphin:

This is exactly what I am looking for. Unfortunately, getting the following error:

 

Failed to create a request in Webhooks by Zapier
Page Not Found

 

I also tried changing the url slightly based on an actual form submission url from chromes devtools/network but getting the same error:

https://docs.google.com/forms/u/0/d/e/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX/formResponse

 

Thanks in advance for any ideas on what to try.

 

It’s been quite some time since you posted here so I expect you’ve already got this sorted, but in case anyone else is also running into that same error I wanted to note that both versions of that URL should work. The presence of a “Page Not Found” error can indicate that there’s an issue accessing the form. If the form has the “Requires Sign-In” option enabled then that may be what’s causing that error.
 

@cam.b.dean:

Just wanted to say THANK YOU, IT WORKED, and your guide ROCKS!

Yay! I’m so pleased to hear the guide was useful to you @cam.b.dean. Happy Zapping! 😁⚡

Reply