Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
94 views
in Technique[技术] by (71.8m points)

Is it possible to send HTTP request from inside Google docs?

I want to send an HTTP request to some REST service from Google drive spreadsheet.

Is this possible?

question from:https://stackoverflow.com/questions/23917189/is-it-possible-to-send-http-request-from-inside-google-docs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using Google Apps Script, you can make HTTP requests to external APIs from inside Google Docs/Sheets/etc. using the UrlFetchApp class:

var url = 'https://gdata.youtube.com/feeds/api/videos?'
    + 'q=skateboarding+dog'
    + '&start-index=21'
    + '&max-results=10'
    + '&v=2';
var response = UrlFetchApp.fetch(url);
Logger.log(response);

Note that:

This service requires the https://www.googleapis.com/auth/script.external_request scope. In most cases Apps Script automatically detects and includes the scopes a script needs, but if you are setting your scopes explicitly you must manually add this scope to use UrlFetchApp.

ref: https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...