gas:example:http_client
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン | |||
| gas:example:http_client [2023/08/23 15:53] – mikoto | gas:example:http_client [2023/08/23 18:52] (現在) – mikoto | ||
|---|---|---|---|
| 行 12: | 行 12: | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | ===== POSTパターン ===== | ||
| + | < | ||
| + | function httpclient() { | ||
| + | const url = ' | ||
| + | const payload = { | ||
| + | title: ' | ||
| + | body: 'This is a sample post.', | ||
| + | userId: 1 | ||
| + | }; | ||
| + | |||
| + | const options = { | ||
| + | method: ' | ||
| + | contentType: | ||
| + | payload: JSON.stringify(payload) | ||
| + | }; | ||
| + | |||
| + | const response = UrlFetchApp.fetch(url, | ||
| + | |||
| + | if (response.getResponseCode() === 201) { | ||
| + | const data = JSON.parse(response.getContentText()); | ||
| + | Logger.log(data); | ||
| + | } else { | ||
| + | Logger.log(' | ||
| + | } | ||
| + | |||
| + | } | ||
| </ | </ | ||
gas/example/http_client.1692773607.txt.gz · 最終更新: 2023/08/23 15:53 by mikoto