Skip to content

Latest commit

 

History

History
55 lines (49 loc) · 2.52 KB

Collaborations.md

File metadata and controls

55 lines (49 loc) · 2.52 KB

Collaborations

Collaborations is a sophisticated mechanism for managing access to to folders. If you would like to give your users the ability to manage collaborations, we recommend using the Share SDK rather than trying to call these methods yourself. The Share SDK contains activities that allow users to manage folder collaborations.

View Collaborators in a Folder

BoxApiFolder folderApi = new BoxApiFolder(session);
BoxListCollaborations collaborations = folderApi.getCollaborationsRequest("folderId").send();

Add a Collaborator to a Folder

Add a collaborator by email address:

BoxApiCollaboration collabApi = new BoxApiCollaboration(session);
BoxCollaboration collaboration = collabApi.getAddRequest("folderId", BoxCollaboration.Role.VIEWER, "[email protected]").send();

Add a user:

BoxApiCollaboration collabApi = new BoxApiCollaboration(session);
// You can either use an existing BoxUser object or create one from the user ID
BoxUser user = BoxUser.createFromId("userId");
BoxCollaboration collaboration = collabApi.getAddRequest("folderId", BoxCollaboration.Role.VIEWER, user).send();

Add a group:

BoxApiCollaboration collabApi = new BoxApiCollaboration(session);
// You can either use an existing BoxGroup object or create one from the group ID
BoxGroup group = BoxGroup.createFromId("groupId");
BoxCollaboration collaboration = collabApi.getAddRequest("folderId", BoxCollaboration.Role.VIEWER, group).send();

Remove a Collaborator from a Folder

BoxApiCollaboration collabApi = new BoxApiCollaboration(session);
collabApi.getDeleteRequest("collaborationId").send();

Update an existing Collaboration

BoxApiCollaboration collabApi = new BoxApiCollaboration(session);
BoxCollaboration updatedCollaboration = collabApi.getUpdateRequest("collaborationId").setNewRole(BoxCollaboration.Role.EDITOR).send();

View Pending Collaborations for the Current User

A "Pending Collaboration" represents a user who has not yet accepted the invitation to join a folder as a collaborator. Most users auto-accept invitations, but some do not. This method retrieves the collaboration invitations that the current user has not yet accepted.

BoxApiCollaboration collabApi = new BoxApiCollaboration(session);
BoxIteratorCollaborations pendingCollabs = collabApi.getPendingCollaborationsRequest().send();