24
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IFTTTのWebhookをGASのPOSTで受け取るときのパラメータ覚書

Last updated at Posted at 2017-12-14

はじめに

ほぼ自分用の覚書

JSONの場合

IFTTTの設定

  • URL: https://script.google.com/macros/s/XXXXXX/exec
  • Method: POST
  • Content Type: application/json
  • Body: {"value1": "moge", "value2": "もげもげ", "value3": "{{TextField}}}

GASの実装

sample.gs
function doPost(e) {
  var jsonString = e.postData.getDataAsString();
  var data = JSON.parse(jsonString);
  var value1 = data.value1; //moge
  var value2 = data.value2; //もげもげ
  var value3 = data.value3; //TextFieldの中身
}

x-www-form-urlencodedの場合

IFTTTの設定

  • URL: https://script.google.com/macros/s/XXXXXX/exec
  • Method: POST
  • Content Type:x-www-form-urlencoded
  • Body: value1=moge&values=hage&values=hoge

GASの実装

sample.gs
function doPost(e) {
  var moge = e.parameters["value1"][0];
  var hage = e.parameters["values"][0];
  var hoge = e.parameters["values"][1];
}

text/plainの場合

IFTTTの設定

  • URL: https://script.google.com/macros/s/XXXXXX/exec
  • Method: POST
  • Content Type:text/plain
  • Body: もげもげ

GASの実装

sample.gs
function doPost(e) {
  var body = e.postData.getDataAsString(); //もげもげ
}
24
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?