teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2018/08/30 20:28

投稿

umyu
umyu

スコア5846

answer CHANGED
@@ -5,13 +5,12 @@
5
5
  > ・HTTPメソッドはPOST(KeyValue型)です。各パラメータごとにKeyとValueをPOSTしてください。
6
6
  > POST(KeyValue型)
7
7
 
8
- とのことなので、クエリ文字列形式でpayload(body)に設定すればよいのではないでしょうか。
8
+ とのことなので、クエリ文字列形式で`payload(body)`に設定すればよいのではないでしょうか。
9
9
 
10
- [UrlFetchApp](https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchAll(Object))
10
+ [UrlFetchApp#fetch](https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String,Object))
11
11
 
12
-
13
12
  1, JSON形式で送信する訳ではないので、"Content-Type": "application/json",は不要。
14
- 2, QueryStringを作成する関数を作成
13
+ 2, GASは[URLSearchParams インターフェイス](https://developer.mozilla.org/ja/docs/Web/API/URLSearchParams)を実装していないので、QueryString(クエリ文字列)を作成する関数を作成
15
14
 
16
15
  ```JavaScript
17
16
  function QueryString(dict) {

1

追記

2018/08/30 20:28

投稿

umyu
umyu

スコア5846

answer CHANGED
@@ -21,7 +21,8 @@
21
21
  }
22
22
  return keys.join("&");
23
23
  }
24
- function getToke(){
24
+ function getToken(){ // getToke→getToken
25
+ var apiUrl = 'https://sateraito-apps-workflow.appspot.com/〇〇〇/api/public/auth';
25
26
  var params = {
26
27
  "api_key": "XXXXX",
27
28
  "impersonate_email": "example@example.com"
@@ -30,7 +31,7 @@
30
31
  "method" : "POST",
31
32
  'payload' : QueryString(params)
32
33
  }
33
- var res = UrlFetchApp.fetch(apiUrl,Request);
34
+ var res = UrlFetchApp.fetch(apiUrl, Request);
34
35
  txt = res.getContentText();
35
36
 
36
37
  Logger.log(txt);