Skip to content
How to Submit Google Forms via Postman and Ajax
2 min read

How to Submit Google Forms via Postman and Ajax

When building basic static websites — like landing pages or personal sites — you often need to connect a contact form. If you’re not using anything beyond HTML, CSS, and JavaScript (as is common with GitHub Pages), Google Forms is a solid option for storing visitor submissions.

Below is the process to connect your site’s contact form to a Google Form without embedding it in an iframe, using a simple HTTP request.

Submitting the Form via Postman

First, go to Google Forms and create a form like this:

Next, open the form and inspect each field to find the name attributes of the inputs, which follow the format entry.{id}:

Inspecting form field names in browser DevTools

Tip: Another quick way to find all the field IDs is to inspect near the <form> tag, where you’ll find hidden inputs whose name attributes start with entry., containing all the form field identifiers:

Hidden fields with entry IDs inside the form tag

Once you have all the name values, you can submit the form by sending an HTTP request with Postman:

  1. Change the end of the form URL from viewform to formResponse:
https://docs.google.com/forms/d/e/1FAIpQLSdnW7ixrovoi7V7sJQihWouPztZL4GoRMAP5SpoVh2UfMhxOQ/viewform
https://docs.google.com/forms/d/e/1FAIpQLSdnW7ixrovoi7V7sJQihWouPztZL4GoRMAP5SpoVh2UfMhxOQ/formResponse
  1. Use text/xml as the Content-Type in the Headers:

Postman headers with Content-Type text/xml

  1. Define the body content. For this example form, the name values for name, email, phone, and message are entry.568194084, entry.1303875942, entry.807958025, and entry.703388132 respectively:

Postman body with form entry fields

If you followed the steps above, you should be able to submit responses to the Google Form using Postman. Feel free to use my example form for testing; responses appear in this spreadsheet.

Submitting the Form via Ajax

Finally, it’s time to connect your web form via Ajax. Here’s a simple jQuery example:

$.ajax({
  url: 'https://docs.google.com/forms/d/e/1FAIpQLSdnW7ixrovoi7V7sJQihWouPztZL4GoRMAP5SpoVh2UfMhxOQ/formResponse',
  type: 'POST',
  crossDomain: true,
  dataType: "xml",
  data: {
    'entry.568194084': 'Value name field',
    'entry.1303875942': 'Value email field',
    'entry.807958025': 'Value phone field',
    'entry.703388132': 'Value message field'
  },
  success: function(jqXHR, textStatus, errorThrown) {
    console.log('Enter on success');
  },
  error: function(jqXHR, textStatus, errorThrown) {
    console.log('Enter on error');
  }
});

As you can see, we only needed to translate the Postman request into jQuery Ajax format. Here’s a minimal working example of a web form connected to the example form; you can try it out right here:

All submissions will appear in the response spreadsheet linked above:

One final note: when using this approach, you may see an error like No 'Access-Control-Allow-Origin' header is present on the requested resource. In other applications this is usually fixed by allowing the origin domain on the server, but Google Forms doesn’t expose such a setting. Despite that, the submission still succeeds, so you can safely ignore this message.

Thanks for reading. If you found this useful, feel free to share it.

Resources: GitHub repository with the code