cancel
Showing results for 
Search instead for 
Did you mean: 

Google Calendar API call from Fiori App developed in WebIDE

kedarT
Active Contributor
0 Kudos

Hi,

Building a Fiori app to change an event on the Google Calendar using the API published by Google.

APIs from Google Calendar are available in api.js. Trying to figure out howo to integrate the same.

Appreciate any help on this.

Accepted Solutions (0)

Answers (1)

Answers (1)

nabheetscn
Active Contributor
0 Kudos

Hello Kedar

You need to consume the googleapis via an XHR request to the API. Did you try that if yes what issues you are facing. For reference you can check this blog

Thanks

Nabheet

kedarT
Active Contributor
0 Kudos

Thanks Nabheet,

I did try the XHR request, it works for GET operation. But, i have a requirement to do a PUT as i need to update the calendar events.

nabheetscn
Active Contributor
0 Kudos

Hello Kedar

For update you will need first authorize and then make a put request. Read the Google calendar api help and examples here and here.

Nabheet

kedarT
Active Contributor
0 Kudos

Thanks Nabheet,

I already did look at it. Issue is how to initiate the gapi library so that we can call the gapi method which would do the authentication and call API.

nabheetscn
Active Contributor
0 Kudos

Kedar if you check the first blog code it is loading the library in the sample code. it is loading gapi via apis.google.com and the second example doing the authorization also.

<html>
  <head>
    <script src="https://apis.google.com/js/api.js"></script>
    <script>
      function start() {
        // Initializes the client with the API key and the Translate API.
        gapi.client.init({
          'apiKey': 'YOUR_API_KEY',
          'discoveryDocs': ['https://www.googleapis.com/discovery/v1/apis/translate/v2/rest'],
        }).then(function() {
          // Executes an API request, and returns a Promise.
          // The method name `language.translations.list` comes from the API discovery.
          return gapi.client.language.translations.list({
            q: 'hello world',
            source: 'en',
            target: 'de',
          });
        }).then(function(response) {
          console.log(response.result.data.translations[0].translatedText);
        }, function(reason) {
          console.log('Error: ' + reason.result.error.message);
        });
      };

      // Loads the JavaScript client library and invokes `start` afterwards.
      gapi.load('client', start);
    </script>
  </head>
  <body>
    <div id="results"></div>
  </body>
</html>