{"id":357,"date":"2025-05-29T01:41:04","date_gmt":"2025-05-28T16:41:04","guid":{"rendered":"https:\/\/cg-method.com\/google\/?p=357"},"modified":"2025-05-29T01:41:05","modified_gmt":"2025-05-28T16:41:05","slug":"gas-post-to-spreadsheet","status":"publish","type":"post","link":"https:\/\/cg-method.com\/google\/gas-post-to-spreadsheet\/","title":{"rendered":"Google\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u2502POST\u901a\u4fe1\u3067\u66f8\u304d\u8fbc\u3080\u65b9\u6cd5"},"content":{"rendered":"\n<p>Google Apps Script\uff08GAS\uff09\u3092\u4f7f\u3063\u3066\u3001<strong>\u5916\u90e8\u304b\u3089\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306bPOST\u901a\u4fe1\u3067\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080<\/strong>\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>GET\/POST\u306e\u4e21\u65b9\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308c\u3070\u3001<strong>\u7c21\u6613\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3084Webhook\u53d7\u3051\u53d6\u308a\u53e3<\/strong>\u3068\u3057\u3066\u6d3b\u7528\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\uff01<\/p>\n\n\n\n<p class=\"is-style-icon_pen\">\u4f7f\u308f\u308c\u305f\u30c4\u30fc\u30eb\u306e\u30ed\u30b0\u3092\u4f5c\u308a\u305f\u304b\u3063\u305f\u306e\u3067\u691c\u8a3c\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u7528\u610f<\/h2>\n\n\n\n<p>\u307e\u305a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ab\u30e9\u30e0\u3092\u6e96\u5099\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"391\" height=\"226\" src=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_04-1.jpg\" alt=\"\" class=\"wp-image-358\" srcset=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_04-1.jpg 391w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_04-1-300x173.jpg 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>script<\/th><th>name<\/th><th>date<\/th><\/tr><\/thead><tbody><tr><td>text.jsx<\/td><td>t_yamada<\/td><td>2019\/08\/11<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">GAS\u3067GET\/POST\u901a\u4fe1\u3092\u51e6\u7406\u3059\u308b\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p>\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30a8\u30c7\u30a3\u30bf\u3067\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>function doGet(e) {\n  var ss        = SpreadsheetApp.getActiveSpreadsheet();\n  var sheet     = ss.getSheetByName(&#39;\u30b7\u30fc\u30c81&#39;);\n  var sheetData = sheet.getRange(&#39;A2:C&#39; + sheet.getLastRow()).getValues();\n\n  var responseList = [];\n  sheetData.map(function(d) {\n    responseList.push({ script: d[0], name: d[1], date: d[2] });\n  });\n\n  var response = {\n    data: responseList,\n    meta: { status: &#39;success&#39; }\n  };\n\n  return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);\n}\n\nfunction doPost(e) {\n  var ss     = SpreadsheetApp.getActiveSpreadsheet();\n  var sheet  = ss.getSheetByName(&#39;\u30b7\u30fc\u30c81&#39;);\n  var data   = JSON.parse(e.postData.contents);\n\n  \/\/ \u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u8ffd\u8a18\n  sheet.appendRow([data.script, data.name, data.date]);\n\n  return ContentService.createTextOutput(JSON.stringify({\n    result: &#39;success&#39;,\n    data: data\n  })).setMimeType(ContentService.MimeType.JSON);\n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u516c\u958b<\/h2>\n\n\n\n<ol class=\"wp-block-list is-style-num_circle\">\n<li>\u30e1\u30cb\u30e5\u30fc \uff1e\u300c\u516c\u958b\u300d\uff1e\u300c\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u5c0e\u5165\u300d<\/li>\n\n\n\n<li>\u300c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u30e6\u30fc\u30b6\u30fc\u300d\u2192\u300c\u5168\u54e1\uff08\u533f\u540d\u30e6\u30fc\u30b6\u30fc\u3092\u542b\u3080\uff09\u300d\u3092\u9078\u629e<\/li>\n\n\n\n<li>\u767a\u884c\u3055\u308c\u305fURL\u3092\u63a7\u3048\u3066\u304a\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1010\" height=\"630\" src=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_05-1.jpg\" alt=\"\" class=\"wp-image-359\" srcset=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_05-1.jpg 1010w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_05-1-300x187.jpg 300w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_05-1-768x479.jpg 768w\" sizes=\"auto, (max-width: 1010px) 100vw, 1010px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Windows\u3067 curl \u3092\u4f7f\u3046\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. curl\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08Windows\uff09<\/h3>\n\n\n\n<p>Mac\u3084Linux\u306b\u306fcurl\u304c\u6700\u521d\u304b\u3089\u5165\u3063\u3066\u3044\u307e\u3059\u304c\u3001Windows\u3067\u306f\u624b\u52d5\u5c0e\u5165\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4ee5\u4e0b\u306eURL\u304b\u3089Windows\u7248\u306ecurl\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\uff1a<br><code>https:\/\/curl.haxx.se\/windows\/<\/code><\/li>\n\n\n\n<li><code>curl-7.65.3-win64-mingw<\/code> \u306a\u3069\u3092\u9078\u629e\u3057\u3066\u5c55\u958b<\/li>\n\n\n\n<li>\u4efb\u610f\u306e\u5834\u6240\uff08\u4f8b\uff1a<code>C:\\curl-7.65.3-win64-mingw\\<\/code>\uff09\u306b\u7f6e\u304d\u307e\u3059<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"> 2. \u52d5\u4f5c\u78ba\u8a8d\uff08\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\uff09<\/h3>\n\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u958b\u304d\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u884c\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>cd C:\\curl-7.65.3-win64-mingw\\bin\\\ncurl --help<\/code><\/pre><\/div>\n\n\n\n<p>\u7121\u4e8b\u306b\u30aa\u30d7\u30b7\u30e7\u30f3\u4e00\u89a7\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GET\u901a\u4fe1\u3067\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>curl -L &quot;https:\/\/script.google.com\/macros\/s\/xxxxxxxxxxxxxxxxxxx\/exec&quot;<\/code><\/pre><\/div>\n\n\n\n<p>\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u5185\u5bb9\u304cJSON\u3067\u53d6\u5f97\u3067\u304d\u305f\u3089\u6210\u529f\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"229\" src=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_06-1-1024x229.jpg\" alt=\"\" class=\"wp-image-360\" srcset=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_06-1-1024x229.jpg 1024w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_06-1-300x67.jpg 300w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_06-1-768x172.jpg 768w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_06-1.jpg 1145w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">POST\u901a\u4fe1\u3067\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u3080<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092Windows\u306e <code>cmd<\/code> \u3067\u5b9f\u884c\u3057\u307e\u3059\uff08JSON\u306e\u56f2\u307f\u306f\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\uff09<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>curl -X POST -H &quot;Content-Type: application\/json&quot; -d &quot;{\\&quot;script\\&quot;:\\&quot;hoge.jsx\\&quot;, \\&quot;name\\&quot;:\\&quot;i_suzuki\\&quot;, \\&quot;date\\&quot;:\\&quot;2019\/08\/11\\&quot;}&quot; -L &quot;https:\/\/script.google.com\/macros\/s\/xxxxxxxxxxxxxxxxxxx\/exec&quot;<\/code><\/pre><\/div>\n\n\n\n<p>Mac\u3084Linux\u306e\u5834\u5408\u306f\u3001\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u3082OK\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>curl -X POST -H &quot;Content-Type: application\/json&quot; -d &#39;{&quot;script&quot;:&quot;hoge.jsx&quot;, &quot;name&quot;:&quot;i_suzuki&quot;, &quot;date&quot;:&quot;2019\/08\/11&quot;}&#39; -L &quot;URL&quot;<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u884c\u7d50\u679c\uff1a\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u30c7\u30fc\u30bf\u304c\u8ffd\u52a0<\/h2>\n\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u3092\u9001\u4fe1\u3059\u308b\u3068\u3001\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b1\u884c\u8ffd\u8a18\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>GAS\u5074\u3067JSON\u3092\u53d7\u3051\u53d6\u308a\u3001\u8868\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u52d5\u4f5c\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_01-1-1024x576.jpg\" alt=\"\" class=\"wp-image-361\" srcset=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_01-1-1024x576.jpg 1024w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_01-1-300x169.jpg 300w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_01-1-768x432.jpg 768w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/05\/Screenshot_2019_0811_01-1.jpg 1045w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GAS\u306e <code>doPost()<\/code> \u3067\u5916\u90e8\u304b\u3089\u306eJSON\u30c7\u30fc\u30bf\u3092\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u4fdd\u5b58\u53ef\u80fd<\/li>\n\n\n\n<li><code>curl<\/code> \u3067\u306eGET\/POST\u901a\u4fe1\u306e\u30c6\u30b9\u30c8\u306f\u3068\u3066\u3082\u4fbf\u5229<\/li>\n\n\n\n<li>Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5316\u3059\u308c\u3070\u3001Slack\u3084\u5916\u90e8\u30c4\u30fc\u30eb\u3068\u9023\u643a\u53ef\u80fd\u306b\uff01<\/li>\n<\/ul>\n\n\n\n<p>\u4eca\u5f8c\u306fWebhook\u3084\u30d5\u30a9\u30fc\u30e0\u306e\u81ea\u52d5\u53d7\u4ed8\u306a\u3069\u306b\u3082\u5fdc\u7528\u3057\u3066\u3044\u3051\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e00\u5ea6\u4f5c\u3063\u3066\u304a\u304f\u3068\u3001\u65e5\u3005\u306e\u81ea\u52d5\u5316\u306b\u5927\u304d\u304f\u8ca2\u732e\u3059\u308b\u306e\u3067\u304a\u3059\u3059\u3081\u3067\u3059\uff01<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Google Apps Script\uff08GAS\uff09\u3092\u4f7f\u3063\u3066\u3001\u5916\u90e8\u304b\u3089\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306bPOST\u901a\u4fe1\u3067\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 GET\/POST\u306e\u4e21\u65b9\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308c\u3070\u3001\u7c21\u6613\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3084Webhook\u53d7\u3051\u53d6\u308a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":362,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[17],"tags":[18,9],"class_list":["post-357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spreadsheets","tag-gas","tag-free"],"_links":{"self":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":1,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"predecessor-version":[{"id":363,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts\/357\/revisions\/363"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/media\/362"}],"wp:attachment":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}