Created
May 30, 2023 05:34
-
-
Save ochilab/ab9a1a7f3f8df77c8805ed75a86ad717 to your computer and use it in GitHub Desktop.
講義資料:GASでHTTPでデータを受け取り、シートに書き込む例(戻り値のjsonは暫定)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doPost(e){ | |
var params = JSON.parse(e.postData.getDataAsString()); | |
var data = params.data; | |
//// 以下の範囲独自処理を書く | |
//シートへの書き込み | |
const ss = SpreadsheetApp.getActiveSpreadsheet(); | |
const sheet = ss.getSheetByName('シート1'); | |
// A2セルを選択 | |
var range = sheet.getRange('A2'); | |
range.setValue(data); //書き込み | |
//result変数は戻り値となるjson形式を保存 | |
var result = { | |
"result":data | |
}; | |
///// 独自処理ここまで | |
var out = ContentService.createTextOutput(); | |
out.setMimeType(ContentService.MimeType.JSON); | |
out.setContent(JSON.stringify(result)); | |
return out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment