Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Last active March 10, 2022 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanaikech/dbabd43df594d27cdd1ecc69a7badb52 to your computer and use it in GitHub Desktop.
Save tanaikech/dbabd43df594d27cdd1ecc69a7badb52 to your computer and use it in GitHub Desktop.
Bug of Create Method of Google Forms API was Removed

Bug of Create Method of Google Forms API was Removed

When I tested Google Forms API, I noticed that when a new Google Form is created by the method of forms.create, there is not title of the created Google Form. So, I have reported this to Google issue tracker. Ref Today, I confirmed that this bug has been removed.

And, when I saw the official document, I noticed that the following document has been added. Ref

In the current stage, when the following curl command is used, a new Google Form with the file title of sampleFormTitle and the form title of sampletitle can be created.

curl -X POST 'https://forms.googleapis.com/v1beta/forms' \
  -d '{"info":{"title":"sampletitle","documentTitle":"sampleFormTitle"}}' \
  -H 'Authorization: Bearer ###accessToken###' \
  -H 'Content-Type: application/json`

For example, when Google Apps Script is used, the script is as follows.

function createForm() {
  const url = "https://forms.googleapis.com/v1beta/forms";
  const obj = {
    info: { title: "sampletitle", documentTitle: "sampleFormTitle" },
  };
  const res = UrlFetchApp.fetch(url, {
    method: "post",
    headers: { authorization: "Bearer " + ScriptApp.getOAuthToken() },
    contentType: "application/json",
    payload: JSON.stringify(obj),
  });
  console.log(res.getContentText());
}

I believe that by this update, Google Forms API will be more useful.

References

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