John John - 27 days ago 5x
Python Question

Derive a Google Form View ID from the Definition ID

When I define a form, it has the url:

I finish adding the questions I want the form to have and use the "Send" button to distribute my form, I do not click the "Include form in email" tickbox. The person that I e-mail the form to now recieves and e-mail inviting them to complete the form, when they do so they end up on a page with the following url:

In my AppEngine / Python 2.7 code I only have access to this id - '1d2Y9R9JJwymtjEbZI6xTMLtS9wB7GDMaopTQeNNNaD0' - my question is how can I get from this original definition id to the view id - '1FAIpQLScINR5rudwEKNVwlvz45ersqk_SO0kNcyN_EM1tJe3mXeFksw'

I have tried using the Google Drive v2 AND v3 REST API's to retrieve the 'definition' file but the response has no reference (that I can see) to this 'view' id.
I have also tried using Google AppsScript FormApp API to retrieve the 'definition' form, but this also contains no reference (that I can see) to the 'view' id.
In all the cases I have tried if I use the 'view' ID as the source the API's return a 404 error indicating that this 'view' ID is not the ID of a Google Drive file.

Any ideas?


Use Google Apps Script to publish a Web App (or use the Execution API) to leaverage the "getPublishedUrl" function

function doGet(theRequest){
  var theDefinitionId = theRequest.parameters.formId;
  var thePublishedUrl = myAPI_(theDefinitionId);
  var output = ContentService.createTextOutput(thePublishedUrl);
  output = output.setMimeType(ContentService.MimeType.JSON);
  return output;

function myAPI_(theDefinitionId){
  var thePublishedUrl = null;
    var existingForm = FormApp.openById(theDefinitionId);
    thePublishedUrl = existingForm.getPublishedUrl();
  } catch (err){
  var theReturn = {publishedUrl: thePublishedUrl};
  var theJSONReturn = JSON.stringify(theReturn);
  return theJSONReturn;