Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Getting the colloborated user id of the folder

Answered
New post

Comments

3 comments

  • Jason

    Hi ,

     

    Thanks for your question! Box's Java SDK includes comments and snippets on how to return information about collaborations on a file or folder:

    https://github.com/box/box-java-sdk/blob/master/doc/collaborations.md

     

    Hope that helps!

     

    Thanks,

    Jason

    0
    Comment actions Permalink
  • tuser5

    Hi ,

    I have gone through the api but we dont have an option to get the collaborated user id. I tried all the methods of the api but it is not returning the user id. Could you please help me on this.

     

    Thanks & Regards,

    Kalyan

    0
    Comment actions Permalink
  • BB_Jake

     

    what exactly are you looking for?

     

    If you retrieve a list of collaborations for a file or folder, you have access to all users/groups listed as collaborators which includes the user's name and login email address.

     

    BoxFolder boxFolder = new BoxFolder(boxAPIConnection, "12345");
        List collaborators = (List) boxFolder.getCollaborations();
        for (BoxCollaboration.Info collaborator : collaborators) {
          if (collaborator.getAccessibleBy() instanceof BoxUser.Info) {
            BoxUser.Info boxUserInfo = (BoxUser.Info) collaborator.getAccessibleBy();
            System.out.println("User name : " + boxUserInfo.getName());
            System.out.println("Email Address : " + boxUserInfo.getLogin());
          } 
          else if (collaborator.getAccessibleBy() instanceof BoxGroup.Info) {
            BoxGroup.Info groupInfo = (BoxGroup.Info) collaborator.getAccessibleBy();
            List boxGroupMembershipInfos = (List) groupInfo.getResource().getMemberships();
            for (BoxGroupMembership.Info membershipInfo : boxGroupMembershipInfos) {
              System.out.println("User name : " + membershipInfo.getUser().getName());
              System.out.println("Email Address : " + membershipInfo.getUser().getLogin());
            }
          }
        }
    0
    Comment actions Permalink

Please sign in to leave a comment.