Bug of Create Method of Google Forms API was Removed

Gists

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

 Share!