ユーザーのすべてのグループを取得します。このグループのメンバー、または管理者レベルの権限を持つユーザーのみがこのAPIを使用できます。
メンバーシップオブジェクトのコレクションを返します。メンバーシップが存在しない場合は、空のコレクションが返されます。
予期しないクライアントエラー。
curl -i -X GET "https://api.box.com/2.0/users/12345/memberships" \
-H "authorization: Bearer <ACCESS_TOKEN>"
await client.memberships.getUserMemberships(user.id);
client.memberships.get_user_memberships(user.id)
await client.Memberships.GetUserMembershipsAsync(userId: user.Id);
BoxUser user = new BoxUser(api, id);
Iterable<BoxGroupMembership.Info> memberships = user.getAllMemberships();
for (BoxGroupMembership.Info membershipInfo : memberships) {
// Do something with the membership.
}
user_memberships = client.user(user_id='33333').get_group_memberships()
for membership in user_memberships:
print(f'User is in the {membership.group.name} group')
BoxCollection<BoxGroupMembership> memberships = await client.GroupsManager
.GetAllGroupMembershipsForUserAsync(userId: "11111");
var userID = '22222';
client.users.getGroupMemberships(userID)
.then(memberships => {
/* memberships -> {
total_count: 1,
entries:
[ { type: 'group_membership',
id: '12345',
user:
{ type: 'user',
id: '22222',
name: 'Alison Wonderland',
login: 'alice@example.com' },
group: { type: 'group', id: '11111', name: 'Employees' },
role: 'member' } ],
limit: 100,
offset: 0 }
*/
});
let iterator = client.groups.listMembershipsForUser(userId: "12345")
iterator.next { result in
switch results {
case let .success(page):
for membership in page.entries {
print("Group Membership with ID \(membership.id) was retrieved")
}
case let .failure(error):
print(error)
}
}
{
"entries": [
{
"created_at": "2012-12-12T10:53:43-08:00",
"group": {
"id": "11446498",
"type": "group",
"group_type": "managed_group",
"name": "Support"
},
"id": "11446498",
"modified_at": "2012-12-12T10:53:43-08:00",
"role": "member",
"type": "group_membership",
"user": {
"id": "11446498",
"type": "user",
"login": "ceo@example.com",
"name": "Aaron Levie"
}
}
],
"limit": 1000,
"offset": 2000,
"order": [
{
"by": "type",
"direction": "ASC"
}
],
"total_count": 5000
}