日本時間5月16日のContent Cloud Summitで、カスタムアプリにBox AI APIを活用する方法を紹介します。

詳細を表示

会社ユーザーのリストを取得

get
https://api.box.com/2.0
/users

会社の全ユーザーのリストを、各ユーザーのuser_idpublic_nameloginとともに返します。

会社全体のユーザーを参照するには、アプリケーションと認証済みユーザーに適切な権限が付与されている必要があります。

リクエスト

bearer [ACCESS_TOKEN]
application/json

クエリパラメータ

stringクエリ内省略可能
my-user-1234

指定したexternal_app_user_id値を持つApp Userに結果を絞り込みます。

アプリユーザーの作成時に、external_app_user_id値を設定できます。その後、この値をこのエンドポイントで使用すると、そのexternal_app_user_id値に一致するすべてのユーザーが見つかります。

string arrayクエリ内省略可能
id,type,name

レスポンスに含める属性のコンマ区切りリスト。このパラメータを使用すると、標準のレスポンスには通常含まれないフィールドをリクエストできます。

このパラメータを指定すると、明示的に指定しない限り標準フィールドはレスポンスに含まれず、リクエストしたフィールドのほかには、Mini版の表示のフィールドしか返されないことに注意してください。

stringクエリ内省略可能
john

nameまたはloginが検索語で始まるユーザーのみに結果を絞り込みます。

外部で管理されているユーザーを検索するには、ユーザー名またはログインが検索語と完全に一致している必要があります。 同時に返されるユーザーは1人のみです。

integer / int64クエリ内省略可能
10001000

返す項目の1ページあたりの最大数。

stringクエリ内省略可能
JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii

結果が返される開始位置のマーカー。マーカーベースのページ割りを使用している場合に使用されます。

これを使用するには、usemarkertrueに設定する必要があります。

integer / int64クエリ内省略可能
10000

レスポンスが開始される項目のオフセット。

オフセットパラメータ値が10,000を超えているクエリは拒否され、400レスポンスが返されます。

booleanクエリ内省略可能
true

オフセットベースのページ割り方式ではなくマーカーベースのページ割り方式を使用するかどうかを指定します。同時に使用できるページ割りの方式は1つのみです。

この値をtrueに設定すると、APIは、レスポンスの次のページを取得するために、このエンドポイントにパラメータとして渡すことができるmarkerフィールドを返します。

stringクエリ内省略可能
managed

指定したタイプのユーザーのみに結果を絞り込みます。

  • allを指定すると、loginまたはnamefilter_termと部分的に一致するすべての種類のユーザーが返されます。ログインがfilter_termと完全に一致した場合は、外部ユーザーのみが返され、その場合に返されるユーザーは、完全に一致したユーザーのみです。
  • managedを指定すると、loginまたはnamefilter_termと部分的に一致するすべての管理対象ユーザーおよびApp Userが返されます。
  • externalを指定すると、loginfilter_termと完全に一致するすべての外部ユーザーが返されます。

次の値のいずれか1つ: all,managed,external

レスポンス

application/jsonUsers

企業内のすべてのユーザーを返します。

予期しないクライアントエラー。

get
会社ユーザーのリストを取得
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X GET "https://api.box.com/2.0/users" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
BoxCollection<BoxUser> users = await client.UsersManager.GetEnterpriseUsersAsync();
Java
Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(api, true, null);

// Get marker
String marker = ((BoxResourceIterable<BoxUser.Info>) users).getNextMarker();
Python
users = client.users(user_type='all')
for user in users:
    print(f'{user.name} (User ID: {user.id})')
Node
client.enterprise.getUsers({usemarker: true, marker: 'JFUirotE56hfyr56FH123'})
	.then(users => {
		/* users -> {
			total_count: 1,
			entries: 
			[ { type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com',
				created_at: '2012-05-03T21:39:11-07:00',
				modified_at: '2012-08-23T14:57:48-07:00',
				language: 'en',
				space_amount: 5368709120,
				space_used: 52947,
				max_upload_size: 104857600,
				status: 'active',
				job_title: '',
				phone: '5555551374',
				address: '10 Cloud Way Los Altos CA',
				avatar_url: 'https://app.box.com/api/avatar/large/deprecated' } ] }
		*/
	});
iOS
let iterator = client.users.listForEnterprise()
iterator.next { result in
    switch results {
    case let .success(page):
        for user in page.entries {
            print("\(user.name) (ID: \(user.id))")
        }

    case let .failure(error):
        print(error)
    }
}

レスポンスの例

{
  "entries": [
    {
      "id": "11446498",
      "type": "user",
      "name": "Aaron Levie",
      "login": "ceo@example.com",
      "created_at": "2012-12-12T10:53:43-08:00",
      "modified_at": "2012-12-12T10:53:43-08:00",
      "language": "en",
      "timezone": "Africa/Bujumbura",
      "space_amount": 11345156112,
      "space_used": 1237009912,
      "max_upload_size": 2147483648,
      "status": "active",
      "job_title": "CEO",
      "phone": "6509241374",
      "address": "900 Jefferson Ave, Redwood City, CA 94063",
      "avatar_url": "https://www.box.com/api/avatar/large/181216415",
      "notification_email": {
        "email": "notifications@example.com",
        "is_confirmed": true
      },
      "role": "admin",
      "tracking_codes": [
        {
          "type": "tracking_code",
          "name": "department",
          "value": "Sales"
        }
      ],
      "can_see_managed_users": true,
      "is_sync_enabled": true,
      "is_external_collab_restricted": true,
      "is_exempt_from_device_limits": true,
      "is_exempt_from_login_verification": true,
      "enterprise": {
        "id": "11446498",
        "type": "enterprise",
        "name": "Acme Inc."
      },
      "my_tags": [
        "important"
      ],
      "hostname": "https://example.app.box.com/",
      "is_platform_access_only": true,
      "external_app_user_id": "my-user-1234"
    }
  ],
  "limit": 1000,
  "offset": 2000,
  "order": [
    {
      "by": "type",
      "direction": "ASC"
    }
  ],
  "total_count": 5000
}