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
4 changes: 4 additions & 0 deletions forms-api/snippets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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).
35 changes: 35 additions & 0 deletions forms-api/snippets/retrieve_all_responses.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START forms_retrieve_all_responses]
function callFormsAPI() {
Logger.log('Calling the Forms API!');
var formId = '<YOUR_FORM_ID>';

// Get OAuth Token
var OAuthToken = ScriptApp.getOAuthToken();
Logger.log('OAuth token is: ' + OAuthToken);
var formsAPIUrl = 'https://forms.googleapis.com/v1beta/forms/' + formId + '/' + 'responses';
Logger.log('formsAPIUrl is: ' + formsAPIUrl);
var options = {
'headers': {
Authorization: 'Bearer ' + OAuthToken,
Accept: 'application/json'
},
'method': 'get'
};
var response = UrlFetchApp.fetch(formsAPIUrl, options);
Logger.log('Response from forms.responses was: ' + response);
}
# [END forms_retrieve_all_responses]