2
2

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 1 year has passed since last update.

GASからKintone REST APIを呼び出す

Posted at

GASからKintoneのREST APIを呼び出す

https://developer.cybozu.io/hc/ja/articles/360000313406
https://developer.cybozu.io/hc/ja/articles/360035992312

GASからデータを1件操作する

レコードを1件取得する

const getKintoneRecord = (app, appApiToken, id) => {
  const apiResponse =  UrlFetchApp.fetch(`${KINTONE_URL}/k/v1/record.json?app=${app}&id=${id}`, {
    method: 'get',
    headers: {
      'X-Cybozu-API-Token': appApiToken
    }
  })
  return apiResponse.getContentText()
}

レコードを1件登録する

const createKintoneRecord = (app, appApiToken, record) => {
  const apiResponse =  UrlFetchApp.fetch(`${KINTONE_URL}/k/v1/record.json`, {
    method: 'post',
    contentType: 'application/json',
    headers: {
      'X-Cybozu-API-Token': appApiToken
    },
    payload: JSON.stringify({app, record})
  })
  return apiResponse.getContentText()
}

レコードを編集する

const updateKintoneRecord = (app, appApiToken, id, record) => {
  const apiResponse =  UrlFetchApp.fetch(`${KINTONE_URL}/k/v1/record.json`, {
    method: 'put',
    contentType: 'application/json',
    headers: {
      'X-Cybozu-API-Token': appApiToken
    },
    payload: JSON.stringify({app, id, record})
  })
  return apiResponse.getContentText()
}

サンプルソース

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?