5
4

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.

kintone と Airtable のAPI連携

5
Last updated at Posted at 2016-03-18

Kintone からの Airtable API 呼び出し

Airtable 側は、呼び出されるAPI しかありませんので連携は、kintone 側からの API 呼び出しになります。
試しに、kinotne カスタム一覧で、Airtable の BASE 「kintone プラグイン一覧」のレコードを取得します。

Airtable のBASE データ

取得する Airtable の BASE (データベース)です。

airtable21.png

Airtable API ドキュメント

BASE の HELP メニューから、API docs をクリックすると、curl による API の呼び出し方が表示されます。

airtable22.png

kintone JavaScript からの Airtable API 呼び出し

カスタム一覧画面から、Airtable API の呼び出しを行います。

jQuery.noConflict();
(function($) {
    "use strict";
    kintone.events.on("app.record.index.show", function(event) {
        if (event.viewId != 5263639) {
            return;
        }
        
        // Airtable GET Records
        var strUrl = "https://api.airtable.com/v0/appodFvpeKE2xc4tX/%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3?";
        strUrl += "view=kintone%20%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E4%B8%80%E8%A6%A7";
        strUrl += "&maxRecords=10";
        var headers = { "Authorization" : "Bearer YOUR_API_KEY" };
        kintone.proxy(strUrl, 'GET', headers, {}).then(function(args) {
            /*  args[0] -> body(文字列)
             *  args[1] -> status(数値)
             *  args[2] -> headers(オブジェクト)
             */
            console.log(args[1], JSON.parse(args[0]), args[2]);
        }, function(error) {
            console.log(error);  //proxy APIのレスポンスボディ(文字列)を表示
        });
 
    });
})(jQuery);

API 実行結果

簡単なコードで、Airtable API の実行が出来ました。
kintone に比べると、応答されるレコード情報の構造がシンプルです。

airtable20.png

5
4
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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?