Create watch as notification for response in Google Forms
@vinay-google y travaille déjà.
Depuis le 28/7/2022.
Évaluation
Cette issue n'a pas encore été évaluée.
Description
Hi!
I'm trying to reproduce a sample in AppsScript that has been published in the Google Documentation for python and Node.
It is this method: https://developers.google.com/forms/api/guides/push-notifications#create_a_watch
So basically, I have a topic created in the Cloud Pub/Sub feature for my project and want to have some kind of notification process as when a new response of Google Form has been submitted. I cannot use an email notification but I'm open to any other solution that provides me the functionality of triggering a subprocess of a Node app.
Here's the use case: For MVP reasons and getting quick results, I have embedded the form as an iframe in my Node app. When users complete the form I need to start a new process with the information provided in the form as the input.
For the time being, I thought about having set up an AppsScript in the form that publishes to a Pub/Sub topic to which the app is subscribed.
However, using the following code:
function createWatch() {
Logger.log('Calling the Forms API!');
var formId = FORMID';
// Get OAuth Token
var OAuthToken = ScriptApp.getOAuthToken();
Logger.log('OAuth token is: ' + OAuthToken);
var formsAPIUrl = 'https://forms.googleapis.com/v1beta/forms/' + formId + '/' + 'watches';
Logger.log('formsAPIUrl is: ' + formsAPIUrl);
var watchRequest = JSON.stringify({
"watch": {
"target": {
"topic": {
"topicName": "projects/xxx/topics/xxx"
}
},
"eventType": "RESPONSES"
}
});
var options = {
'headers': {
Authorization: 'Bearer ' + OAuthToken,
Accept: 'application/json'
},
'method': 'post',
'muteHttpExceptions': true,
'payload': watchRequest
};
var response = UrlFetchApp.fetch(formsAPIUrl, options);
Logger.log('Response from forms.responses was: ' + response);
}
... I get the following response:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"{\"watch\":{\"target\":{\"topic\":{\"topicName\":\"projects/fachmarkt-manager/topics/employee-onboarding\"}},\"eventType\":\"RESPONSES\"}}\": Cannot bind query parameter. Field '{\"watch\":{\"target\":{\"topic\":{\"topicName\":\"projects/fachmarkt-manager/topics/employee-onboarding\"}},\"eventType\":\"RESPONSES\"}}' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"{\"watch\":{\"target\":{\"topic\":{\"topicName\":\"projects/fachmarkt-manager/topics/employee-onboarding\"}},\"eventType\":\"RESPONSES\"}}\": Cannot bind query parameter. Field '{\"watch\":{\"target\":{\"topic\":{\"topicName\":\"projects/fachmarkt-manager/topics/employee-onboarding\"}},\"eventType\":\"RESPONSES\"}}' could not be found in request message."
}
]
}
]
}
}
I have also tried to drop the stringify of the payload but it results in the same error.
Any chances of fixing this?
- Langage dominant
- JavaScript
- Étoiles
- 5.2k
- Forks
- 2k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de googleworkspace/apps-script-samples
-
Alvin Litana MirasolOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 1/100
googleworkspace/apps-script-samples#659 · 1 commentaire · 1 réaction ·
-
Password resetOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
googleworkspace/apps-script-samples#654 · 2 réactions ·
-
cod gsOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 10/100
googleworkspace/apps-script-samples#651 · 1 réaction ·
-
tespogromeOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 1/100
googleworkspace/apps-script-samples#624 · 1 réaction ·
-
Get_order_manually.gsPeut-être à nouveau libre @vinay-google l’a pris il y a 245 jours, et aucune pull request n’est ouverte. Ouverte
googleworkspace/apps-script-samples#616 · 1 personne assignée ·
Toutes les issues de googleworkspace/apps-script-samples
Issues similaires
-
Four problem loader browser tests fail on WindowsPeut-être pris @Patriciaath999 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
juice-shop/juice-shop#3686 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
TheOdinProject/curriculum#31465 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
TurboDocx/html-to-docx#254 ·
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour