Creates a group membership
id,type,name
A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.
Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested.
Custom configuration for the permissions an admin
if a group will receive. This option has no effect
on members with a role of member
.
Setting these permissions overwrites the default access levels of an admin.
Specifying a value of "null" for this object will disable all configurable permissions. Specifying permissions will set them accordingly, omitted permissions will be enabled by default.
true
A key value pair of custom permissions.
The group to add the user to.
4545523
The ID of the group to add the user to
member
The role of the user in the group.
Value is one of member
,admin
The user to add to the group.
1434325
The ID of the user to add to the group
Returns a new group membership object.
An unexpected client error.
curl -X POST https://api.box.com/2.0/group_memberships \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json" '
-d '{
"user": {
"id": "1434325"
},
"group": {
"id": "4545523"
}
}'
var requestParams = new BoxGroupMembershipRequest()
{
User = new BoxRequestEntity()
{
Id = "22222"
},
Group = new BoxGroupRequest()
{
Id = "11111"
}
};
BoxGroupMembership membership = await client.GroupsManager.AddMemberToGroupAsync(requestParams);
BoxGroup group = new BoxGroup(api, "groupID");
BoxUser user = new BoxUser(api, "userID");
BoxGroupMembership.Info groupMembershipInfo = group.addMembership(user);
user = client.user('1111')
membership = client.group(group_id='11111').add_member(user)
print('Added {0} to the {1} group!'.format(membership.user.name, membership.group.name))
var groupID = '11111';
var userID = '22222';
client.groups.addUser(groupID, userID, {role: client.groups.userRoles.MEMBER})
.then(membership => {
/* membership -> {
type: 'group_membership',
id: '33333',
user:
{ type: 'user',
id: '22222',
name: 'Alison Wonderland',
login: 'alice@example.com' },
group: { type: 'group', id: '11111', name: 'Employees' },
role: 'member',
configurable_permissions:
{ can_run_reports: false,
can_instant_login: false,
can_create_accounts: false,
can_edit_accounts: false } }
*/
});
client.createMembership(userId: "54321", groupId: "11111", role: .admin, configurablePermission: .value(ConfigurablePermissionData(canRunReports: true, canInstantLogin: true, canCreateAccounts: false, canEditAccounts: true))) {
(result: Result<GroupMembership, BoxSDKError>) in
guard case let .success(membership) = result else {
print("Error creating group membership")
return
}
print("Group membership for group \(membership.group?.name) was created")
}