Retrieves all the groups for a user. The user making an API call must have admin permissions to inspect the enterprise's groups.
12345The ID of the user.
10001000The maximum number of items to return per page.
10000The offset of the item at which to begin the response.
Returns a collection of membership objects. If there are no memberships, an empty collection will be returned.
An unexpected client error.
curl -X GET https://api.box.com/2.0/users/12345/memberships \
-H 'Authorization: Bearer <ACCESS_TOKEN>'BoxCollection<BoxGroupMembership> memberships = await client.GroupsManager
.GetAllGroupMembershipsForUserAsync(userId: "11111");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('User is in the {0} group'format(membership.group.name))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 }
*/
});client.groups.listMembershipsForUser(userId: "12345") {
switch results {
case let .success(iterator):
for i in 1 ... 10 {
iterator.next { result in
switch result {
case let .success(membership):
print("Group Membership with ID \(membership.id) was retrieved")
case let .failure(error):
print(error)
}
}
}
case let .failure(error):
print(error)
}
}