Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions forms-api/demos/AppsScriptFormsAPIWebApp/FormsAPI.gs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

// Global constants. Customize as needed.
const formsAPIUrl = 'https://forms.googleapis.com/v1beta/forms/';
const formsAPIUrl = 'https://forms.googleapis.com/v1/forms/';
const formId = '<YOUR_FORM_ID>';
const topicName = 'projects/<YOUR_TOPIC_PATH>';

Expand All @@ -22,7 +22,7 @@ const topicName = 'projects/<YOUR_TOPIC_PATH>';

/**
* Forms API Method: forms.create
* POST https://forms.googleapis.com/v1beta/forms
* POST https://forms.googleapis.com/v1/forms
*/
function create(title) {
const accessToken = ScriptApp.getOAuthToken();
Expand Down Expand Up @@ -50,7 +50,7 @@ function create(title) {

/**
* Forms API Method: forms.get
* GET https://forms.googleapis.com/v1beta/forms/{formId}/responses/{responseId}
* GET https://forms.googleapis.com/v1/forms/{formId}/responses/{responseId}
*/
function get(formId) {
const accessToken = ScriptApp.getOAuthToken();
Expand All @@ -76,7 +76,7 @@ function get(formId) {

/**
* Forms API Method: forms.batchUpdate
* POST https://forms.googleapis.com/v1beta/forms/{formId}:batchUpdate
* POST https://forms.googleapis.com/v1/forms/{formId}:batchUpdate
*/
function batchUpdate(formId) {
const accessToken = ScriptApp.getOAuthToken();
Expand Down Expand Up @@ -111,7 +111,7 @@ function batchUpdate(formId) {

/**
* Forms API Method: forms.responses.get
* GET https://forms.googleapis.com/v1beta/forms/{formId}/responses/{responseId}
* GET https://forms.googleapis.com/v1/forms/{formId}/responses/{responseId}
*/
function responsesGet(formId, responseId) {
const accessToken = ScriptApp.getOAuthToken();
Expand All @@ -137,7 +137,7 @@ function responsesGet(formId, responseId) {

/**
* Forms API Method: forms.responses.list
* GET https://forms.googleapis.com/v1beta/forms/{formId}/responses
* GET https://forms.googleapis.com/v1/forms/{formId}/responses
*/
function responsesList(formId) {
const accessToken = ScriptApp.getOAuthToken();
Expand All @@ -163,7 +163,7 @@ function responsesList(formId) {

/**
* Forms API Method: forms.watches.create
* POST https://forms.googleapis.com/v1beta/forms/{formId}/watches
* POST https://forms.googleapis.com/v1/forms/{formId}/watches
*/
function createWatch(formId) {
let accessToken = ScriptApp.getOAuthToken();
Expand Down Expand Up @@ -200,7 +200,7 @@ function createWatch(formId) {

/**
* Forms API Method: forms.watches.delete
* DELETE https://forms.googleapis.com/v1beta/forms/{formId}/watches/{watchId}
* DELETE https://forms.googleapis.com/v1/forms/{formId}/watches/{watchId}
*/
function deleteWatch(formId, watchId) {
let accessToken = ScriptApp.getOAuthToken();
Expand Down Expand Up @@ -230,7 +230,7 @@ function deleteWatch(formId, watchId) {

/**
* Forms API Method: forms.watches.list
* GET https://forms.googleapis.com/v1beta/forms/{formId}/watches
* GET https://forms.googleapis.com/v1/forms/{formId}/watches
*/
function watchesList(formId) {
Logger.log('formId is: ' + formId);
Expand All @@ -255,7 +255,7 @@ function watchesList(formId) {

/**
* Forms API Method: forms.watches.renew
* POST https://forms.googleapis.com/v1beta/forms/{formId}/watches/{watchId}:renew
* POST https://forms.googleapis.com/v1/forms/{formId}/watches/{watchId}:renew
*/
function renewWatch(formId, watchId) {
let accessToken = ScriptApp.getOAuthToken();
Expand Down
18 changes: 9 additions & 9 deletions forms-api/demos/AppsScriptFormsAPIWebApp/Main.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.create</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms/create" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms/create" target="_blank">(spec)</a><br />
Form title: <input type="text" id="newFormTitle" class="formInputs" value="My new Form!">
<button id="createButton" onclick="create()">Create
Form</button>
Expand All @@ -267,15 +267,15 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.get</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms/get" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms/get" target="_blank">(spec)</a><br />
<button id="getButton" onclick="get()">Get Form by id</button>
</div>

</tr>
<tr>
<div>
<b>forms.batchUpdate</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms/batchUpdate" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms/batchUpdate" target="_blank">(spec)</a><br />
<!--Form id: <input type="text" id="batchId" class="formInputs" value="<?= formId ?>" ><br/>-->
<button id="batchUpdateButton" onclick="batchUpdate()">batchUpdate</button>
</div>
Expand All @@ -284,7 +284,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.responses.list</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms.responses/list" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms.responses/list" target="_blank">(spec)</a><br />
<button id="respListButton" onclick="responsesList()">List a
form's responses</button>
</div>
Expand All @@ -293,7 +293,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.responses.get</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms.responses/get" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms.responses/get" target="_blank">(spec)</a><br />
Response id: <input type="text" id="responseId" class="formInputs"><br />
<button id="getListButton" onclick="responsesGet()">Get one
response from the form</button>
Expand All @@ -303,7 +303,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.watches.create</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms.watches/create" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms.watches/create" target="_blank">(spec)</a><br />
<button id="createWatchButton" onclick="createWatch()">Create
Watch</button>
</div>
Expand All @@ -312,7 +312,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.watches.delete</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms.watches/delete" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms.watches/delete" target="_blank">(spec)</a><br />
Watch id: <input type="text" id="watchId" class="formInputs"><br />
<button id="deleteWatchButton" onclick="deleteWatch()">Delete
Watch</button>
Expand All @@ -322,7 +322,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.watches.list</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms.watches/list" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms.watches/list" target="_blank">(spec)</a><br />
<button id="watchListButton" onclick="watchesList()">Get Watches
by Form id</button>
</div>
Expand All @@ -331,7 +331,7 @@ <h2><img src="https://www.gstatic.com/images/branding/product/2x/forms_2020q4_48
<tr>
<div>
<b>forms.watches.renew</b>
<a href="https://developers.google.com/forms/api/reference/rest/v1beta/forms.watches/renew" target="_blank">(spec)</a><br />
<a href="https://developers.google.com/forms/api/reference/rest/v1/forms.watches/renew" target="_blank">(spec)</a><br />
Watch id:<input type="text" id="renewWatchId" class="formInputs"><br />
<button id="renewWatchButton" onclick="renewWatch()">Renew
Watch</button>
Expand Down
6 changes: 2 additions & 4 deletions forms-api/snippets/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Forms API

The Google Forms API is currently in Restricted Beta. To use the API and these
samples prior to General Availability, your Google Cloud project must be
allowlisted. To request that your project be allowlisted, complete the
[Early Adopter Program application](https://developers.google.com/forms/api/eap).
To run, you must set up your GCP project to use the Forms API.
See: https://developers.google.com/forms/api/
4 changes: 2 additions & 2 deletions forms-api/snippets/retrieve_all_responses.gs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
// Get OAuth Token
var OAuthToken = ScriptApp.getOAuthToken();
Logger.log('OAuth token is: ' + OAuthToken);
var formsAPIUrl = 'https://forms.googleapis.com/v1beta/forms/' + formId + '/' + 'responses';
var formsAPIUrl = 'https://forms.googleapis.com/v1/forms/' + formId + '/' + 'responses';
Logger.log('formsAPIUrl is: ' + formsAPIUrl);
var options = {
'headers': {
Expand Down