Search code examples
javascriptgoogle-formsreferenceerror

I'am trying to use the google Forms API. But there is a reference error


I'm trying to use the Google Form API. When I'm trying to use FormApp.openByUrl(). But I'm getting an ReferenceError. Here is my code:

I already tried to import the API. But it didn't work.

<html>
<head>
    <title>Test</title>
    <script src="https://apis.google.com/js/api.js"></script>
</head>
<body>
    <script>
        var form = FormApp.openByUrl('https://docs.google.com/forms/d/SOME-FORM/edit');
        var formResponses = form.getResponses();
    </script>
</body>
</html>

The console output:

Uncaught ReferenceError: FormApp is not defined
    at (index):9
(anonymous) @ (index):9

It should just do nothing, but it's throwing an exception.


Solution

  • The API you are trying to use is for scripts embedded into a Google Form via the Script Editor.

    screenshot

    It has nothing to do with the script https://apis.google.com/js/api.js which is for connecting to Google APIs from other websites.