建立空間

information

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

目錄

建立空間

使用範本建立空間

  • 如果不使用空格功能,則會發生錯誤。
  • 如果禁用了訪客空間功能,則在嘗試創建訪客空間時將發生錯誤。

URL

https://sample.cybozu.com/k/v1/template/space.json

即使您想創建訪客空間,也要在上面的URL上運行API。

HTTP 方法

POST

所需許可權

  • 空間創建許可權
    如果要將其創建為訪客空間,則必須具有創建訪客空間的許可權。

請求

參數
參數名稱 必須 說明
id 數位或字串 必須 要創建的空間的範本 ID
name 字串 必須 要創建的空間的名稱
members 陣列 必須 取得空間成員的資訊
如果未指定一個或多個空間管理員,或者指定以下任何使用者,則會發生錯誤。
  • 不使用kintone的使用者
  • 停用中的使用者
  • 操作使用者
members[].entity 物件 必須 更新空間的成員
您不能指定來賓使用者。
members[].entity.type 字串 必須 更新空間的成員
您可以指定以下值:
  • USER:使用者
  • GROUP:群組
  • ORGANIZATION:組織
members[].entity.code 字串 必須 更新空間的成員
members[].isAdmin 布爾值或字串 條件必填項 是否將成員設為空間管理員
  • true:將成員設為空間管理員
  • false:不要將成員設為空間管理員
如果省略,則設置"false"。
如果未設置至少一個空間管理員,則會收到錯誤。
members[].includeSubs 布爾值或字串 自選 是否包括子組織
  • true:包含下級組織
  • false:不包括子組織
如果省略,則設置"false"。
entity.type 是"組織"。
isPrivate 布爾值或字串 自選 是否將空間設為私密
  • true: 私人空間
  • false: 公共空間
如果省略,則設置"false"。
isGuest 如果為 「true」,則設置為 「true」。
isGuest 布爾值或字串 自選 是否將空間創建為客人空間
  • true:創建為訪客空間
  • false:創建為常規空間
如果省略,則設置"false"。
如果未啟用訪客空間, true 則會發生錯誤。
fixedMember 布爾值或字串 自選 是否禁止每個使用者離開聊天室或取消關注話題
  • true:禁止
  • false:允許
如果省略,則設置"false"。
示例請求
頁眉
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
{
  "id": 1,
  "name": "Sample space",
  "members": [
    {
      "entity": {
        "type": "USER",
        "code": "user1"
      },
      "isAdmin": true
    },
    {
      "entity": {
        "type": "GROUP",
        "code": "group1"
      },
      "isAdmin": false
    },
    {
      "entity": {
        "type": "ORGANIZATION",
        "code": "org1"
      },
      "isAdmin": false,
      "includeSubs": true
    }
  ]
}

回應

財產
屬性名稱 說明
id 字串 已創建空間的空間ID
示例回應
1
2
3
{
  "id": "1"
}

示例代碼

使用 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
curl -X POST 'https://sample.cybozu.com/k/v1/template/space.json' \
  -H 'X-Cybozu-Authorization: QWRtaW5pc3RyYXRvcjpjeWJvenU=' \
  -H 'Content-Type: application/json' \
  -d '{
    "id": 1,
    "name": "Sample space",
    "members": [
      {
        "entity": {
          "type": "USER",
          "code": "user1"
        },
        "isAdmin": true
      },
      {
        "entity": {
          "type": "GROUP",
          "code": "group1"
        },
        "isAdmin": false
      },
      {
        "entity": {
          "type": "ORGANIZATION",
          "code": "org1"
        },
        "isAdmin": false,
        "includeSubs": true
      }
    ]
  }'
發送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
const body = {
  id: 1,
  name: 'Sample space',
  members: [
    {
      entity: {
        type: 'USER',
        code: 'user1'
      },
      isAdmin: true
    },
    {
      entity: {
        type: 'GROUP',
        code: 'group1'
      },
      isAdmin: false
    },
    {
      entity: {
        type: 'ORGANIZATION',
        code: 'org1'
      },
      isAdmin: false,
      includeSubs: true
    }
  ]
};

await kintone.api(kintone.api.url('/k/v1/template/space.json', true), 'POST', body);