LoginSignup
1
1

More than 3 years have passed since last update.

GASで公開してからコードを変更しても反映されない(メモ)

Last updated at Posted at 2020-11-02

e.parameter.[Key] で初めはパラメータキーとして[text]という値を受け取っていたが、これを[body]に変えて、再度WebhookのURLを叩いても値を受け取れなかった。

WebhookURL
https://script.google.com/macros/~?text=hello!  →textを取得できる
https://script.google.com/macros/~?body=hello!  →bodyを取得できない

元のコード

.gs
// GETリクエスト
function doGet(e) {
  // textというキーに値があればそれをスプレッドシートに書き込みます(URLパラメータ)
  // データ内容を返します
  const data = { text: `GET ` + e.parameter.text };
  return ContentService.createTextOutput(JSON.stringify(data));
}

変更後のコード

.gs
// GETリクエスト
function doGet(e) {
  // bodyというキーに値があればそれをスプレッドシートに書き込みます(URLパラメータ)
  // データ内容を返します
  const data = { text: `GET ` + e.parameter.body};
  return ContentService.createTextOutput(JSON.stringify(data));
}

結論(解決)

保存して、再度WebhookのURLを取得しなおせば上手くいった。
恐らく、アプリとして公開した時点で保存?されるのだろうと思う。
公開してからコードを書き換える場合は、要注意としてメモ。

1
1
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
1
1