更改 JavaScript/CSS 自訂設置

information

本頁面使用機器翻譯而成。
機器翻譯免責聲明 (External link)

目錄

透過JavaScript/CSS自訂

更改應用的 JavaScript/CSS 自定義設置。

此 API 在測試環境中修改應用。
如果要將更改傳播到生產環境,請運行此 API,然後 運行將應用設置傳播到生產環境的 API

URL

常規應用
https://sample.cybozu.com/k/v1/preview/app/customize.json
建立訪客空間
https://sample.cybozu.com/k/guest/GUEST_SPACE_ID/v1/preview/app/customize.json

HTTP 方法

PUT

所需許可權

  • kintone系統管理
  • 應用程式管理

請求

參數
參數名稱 必須 說明
app 數位或字串 必須 應用ID
scope 字串 自選 定製範圍
  • ALL:套用於所有使用者
  • ADMIN:如果您只是應用程式的管理員
  • NONE:停用
desktop 物件 自選 有關電腦上載入的檔案的資訊
desktop.js 陣列 自選 JavaScript檔案
desktop.js[].type 字串 自選 如何指定檔
  • URL:按 URL 指定時
  • FILE:上傳和指定時
desktop.js[].url 字串 自選 檔的 URL
desktop.js[].type 當為"URL"時指定。
desktop.js[].file 您總共最多可以指定 30 個。
desktop.js[].file 物件 自選 附件資訊
desktop.js[].type 當為"FILE"時指定。
desktop.js[].url 您總共最多可以指定 30 個。
desktop.js[].file.fileKey 字串 自選 API](/kintone/docs/rest-api/files/upload-file/) 獲取的檔案金鑰,用於上傳檔
如果要保留現有檔,請指定 API 獲取的相同參數的 key 以取得 JavaScript/CSS 自定義設定(獲取測試環境的設置)。
desktop.css 陣列 自選 CSS 檔案清單
desktop.css[].type 字串 自選 如何指定檔
  • URL:按 URL 指定時
  • FILE:上傳和指定時
desktop.css[].url 字串 自選 檔的 URL
desktop.css[].type 當為"URL"時指定。
desktop.css[].file 您總共最多可以指定 30 個。
desktop.css[].file 物件 自選 附件資訊
desktop.css[].type 當為"FILE"時指定。
desktop.css[].url 您總共最多可以指定 30 個。
desktop.css[].file.fileKey 字串 自選 API](/kintone/docs/rest-api/files/upload-file/) 獲取的檔案金鑰,用於上傳檔
如果要保留現有檔,請指定 API 獲取的相同參數的 key 以取得 JavaScript/CSS 自定義設定(獲取測試環境的設置)。
mobile 物件 自選 有關在行動裝置上載入的檔案的資訊
mobile.js 陣列 自選 JavaScript檔案
mobile.js[].type 字串 自選 如何指定檔
  • URL:按 URL 指定時
  • FILE:上傳和指定時
mobile.js[].url 字串 自選 檔的 URL
mobile.js[].type 當為"URL"時指定。
mobile.js[].file 您總共最多可以指定 30 個。
mobile.js[].file 物件 自選 附件資訊
mobile.js[].type 當為"FILE"時指定。
mobile.js[].url 您總共最多可以指定 30 個。
mobile.js[].file.fileKey 字串 自選 API](/kintone/docs/rest-api/files/upload-file/) 獲取的檔案金鑰,用於上傳檔
如果要保留現有檔,請指定 API 獲取的相同參數的 key 以取得 JavaScript/CSS 自定義設定(獲取測試環境的設置)。
mobile.css 陣列 自選 CSS 檔案清單
mobile.css[].type 字串 自選 如何指定檔
  • URL:按 URL 指定時
  • FILE:上傳和指定時
mobile.css[].url 字串 自選 檔的 URL
mobile.css[].type 當為"URL"時指定。
mobile.css[].file 您總共最多可以指定 30 個。
mobile.css[].file 物件 自選 附件資訊
mobile.css[].type 當為"FILE"時指定。
mobile.css[].url 您總共最多可以指定 30 個。
mobile.css[].file.fileKey 字串 自選 API](/kintone/docs/rest-api/files/upload-file/) 獲取的檔案金鑰,用於上傳檔
如果要保留現有檔,請指定 API 獲取的相同參數的 key 以取得 JavaScript/CSS 自定義設定(獲取測試環境的設置)。
revision 數位或字串 自選 預期修訂號
如果與實際修訂號不匹配,則會發生錯誤,並且不會更改設置。
如果指定值"-1"或未指定值,則不會驗證修訂號。
示例請求
頁眉
1
2
3
4
{
  "X-Cybozu-Authorization": "QWRtaW5pc3RyYXRvcjpjeWJvenU=",
  "Content-Type": "application/json"
}

關於請求頭,請參見 kintone REST API的通用規範

身體
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "app": 21,
  "scope": "ALL",
  "desktop": {
    "js": [
      {
        "type": "URL",
        "url": "https://www.example.com/example.js"
      },
      {
        "type": "FILE",
        "file": {
          "fileKey": "ddfc8e89-7aa3-4350-b9ab-3a75c9cf46b3"
        }
      }
    ],
    "css": []
  },
  "mobile": {
    "js": [
      {
        "type": "FILE",
        "file": {
          "fileKey": "20150519023802B3EB762E870645F889B22F9D4F1F3059023"
        }
      },
      {
        "type": "URL",
        "url": "https://www.example.com/example-mobile.js"
      }
    ],
    "css": []
  },
  "revision": 2
}

回應

財產
屬性名稱 值類型 說明
revision 字串 更改應用設置后的修訂號
示例回應
1
2
3
{
  "revision": "3"
}

樣本

使用 curl 的請求
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
curl -X PUT 'https://sample.cybozu.com/k/v1/preview/app/customize.json' \
  -H 'X-Cybozu-Authorization": "QWRtaW5pc3RyYXRvcjpjeWJvenU=' \
  -H 'Content-Type: application/json' \
  -d '{
    "app": kintone.app.getId(),
    "scope": "ALL",
    "desktop": {
      "js": [
        {
          "type": "URL",
          "url": "https://www.example.com/example.js"
        },
        {
          "type": "FILE",
          "file": {
            "fileKey": "ddfc8e89-7aa3-4350-b9ab-3a75c9cf46b3"
          }
        }
      ],
      "css": []
    },
    "mobile": {
      "js": [
        {
          "type": "FILE",
          "file": {
            "fileKey": "20150519023802B3EB762E870645F889B22F9D4F1F3059023"
          }
        },
        {
          "type": "URL",
          "url": "https://www.example.com/example-mobile.js"
        }
      ],
      "css": []
    }
  }'
發送kintone REST API請求 使用API 發送請求
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const body = {
  app: kintone.app.getId(),
  scope: 'ALL',
  desktop: {
    js: [
      {
        type: 'URL',
        url: 'https://www.example.com/example.js'
      },
      {
        type: 'FILE',
        file: {
          fileKey: 'ddfc8e89-7aa3-4350-b9ab-3a75c9cf46b3'
        }
      }
    ],
    css: []
  },
  mobile: {
    js: [
      {
        type: 'FILE',
        file: {
          fileKey: '20150519023802B3EB762E870645F889B22F9D4F1F3059023'
        }
      },
      {
        type: 'URL',
        url: 'https://www.example.com/example-mobile.js'
      }
    ],
    css: []
  }
};

await kintone.api(kintone.api.url('/k/v1/preview/app/customize.json', true), 'PUT', body);

限制

  • 不能使用 API 令牌。