1

In AppScript, I wrote this snippet of code to create a google form response, and get the edit link:

function createResponseTest() {
   var test_form = FormApp.create('test-form').setAllowResponseEdits(true);
   // Add a required item
   test_form.addTextItem().setRequired(true);

   // Create a blank response that hasn't completed the item
   var FormResponse = test_form.createResponse();
   const res = FormResponse.submit();
   const link = res.getEditResponseUrl();

   // Get a unique link to the response
   console.log(link);
}

I have looked through the Google Forms documentation, but I don't see a method to create a google form response given a form ID, as is possible in Appscript (see docs here).

I want to run the line:

test_form.createResponse()

from my server, so I don't need to use AppScript at all, but I can't find how to do this.

Am I missing something, or is the Google Form API not feature-complete?

Edit:

I have requested this as a feature through the issue tracker. Track its progress here!

Peter S
  • 827
  • 1
  • 8
  • 24

1 Answers1

2

It's not possible. It seems that the Apps Script functions and Forms REST API are meant to be different. From the documentation:

Both the REST API and the Forms Service on Apps Script support Forms features that the other does not. (...) However, certain features are unlikely to ever be supported, as described below.

The REST API does not plan to support:

  • Submitting form responses
  • Including detailed form or response data in the body of pub/sub notifications

I'm not sure why this is the case. The Forms API was launched recently compared to its cousins, so that could be a partial reason, but it doesn't seem like they ever intend to add this feature. Maybe they want users to actually use the Google Forms interface instead of it turning into just a backend to some other UI. They still offer the option in Apps Script, but this has more stringent quotas than the regular API, so it would be more difficult to implement at a large scale. This is just my conjecture, though.

As a workaround you could still create an Apps Script Web App to act as a webhook receiving POST requests from your server and create the responses that way. You'd just need to create the initial script to fill out a response and then work from your server.

Reference:

Daniel
  • 3,157
  • 2
  • 7
  • 15
  • 2
    To OP, you can request this feature in the [issuetracker](https://developers.google.com/forms/api/support) – TheMaster Apr 11 '23 at 21:13
  • Hi @Daniel, Do you know what the applicable limit here would be in Apps Script? "Properties read/write -- 50,000 / day"? I don't see anything form or Response related. – Peter S Apr 11 '23 at 23:34
  • I mentioned the limits in more general terms, not thinking of a specific one. After looking closely, I think the closest applicable one would be "Simultaneous executions", so you wouldn't be able to have many users generating responses with your script. Aside from that I don't see anything else, but there could be something undocumented. You may or may not find out depending on your use. The "properties" are [something else](https://developers.google.com/apps-script/guides/properties). – Daniel Apr 12 '23 at 20:01