GAS/外部通信

基本

UrlFetchApp.fetch を使えばいい

var res = UrlFetchApp.fetch(
    "https://example.com/",
    { muteHttpExceptions: true }
);
 
if(res.getResponseCode() != 200){
    // 何かエラー処理
}
// res から何か取り出す。

fetch の引数に URL だけ渡すと 200番以外は例外発生でプログラムが止まってしまうのだが、 muteHttpExceptions を指定するとあとで Response Code を検証できる

google/google_apps_script/request_outside/start.txt · 最終更新: 2018-11-16 11:46 by ore