Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.

Forum Discussion

skaros's avatar
skaros
Helpful | Level 6
9 years ago
Solved

add members to a file/folder

Hi,

I am using the dropbox-sdk-java, via Maven, and i unable to find a way to add members to a file(and later to a folder).

Could you provide with some pointers?

I think i have to use

DbxRawClientV2

DbxUserSharingRequests

But for one, i can not itialize DbxRawClientV2, if I try

DbxRequestConfig config = new DbxRequestConfig("example/DbApi");
DbxRawClientV2 rawClient=new DbxRawClientV2(config, getToken(AuthorizationFile));

I am getting

Cannot instantiate the type DbxRawClientV2

Thanks

 

  • You don't need to use DbxRawClientV2. You should instead use DbxClientV2, as shown in the examples, e.g., here.

     

    Calling addFileMember would look like this:

     

    DbxRequestConfig config = new DbxRequestConfig("example");
    DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
    
    List<MemberSelector> newMembers = new ArrayList<MemberSelector>();
    MemberSelector newMember = MemberSelector.email("dbapitesting@gmail.com");
    newMembers.add(newMember);
    
    List<FileMemberActionResult> fileMemberActionResults = client.sharing().addFileMember("/test.txt", newMembers);
    System.out.print(fileMemberActionResults);

     

     

3 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    You don't need to use DbxRawClientV2. You should instead use DbxClientV2, as shown in the examples, e.g., here.

     

    Calling addFileMember would look like this:

     

    DbxRequestConfig config = new DbxRequestConfig("example");
    DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
    
    List<MemberSelector> newMembers = new ArrayList<MemberSelector>();
    MemberSelector newMember = MemberSelector.email("dbapitesting@gmail.com");
    newMembers.add(newMember);
    
    List<FileMemberActionResult> fileMemberActionResults = client.sharing().addFileMember("/test.txt", newMembers);
    System.out.print(fileMemberActionResults);

     

     

  • skaros's avatar
    skaros
    Helpful | Level 6
    9 years ago

    Thanks a lot!

    Why dont you add these on StackOverflow docs? It would be usefull for everyone to see

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    I just wrote this for this thread, but I'll make a note to post it on StackOverflow later. Thanks!

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,039 PostsLatest Activity: 2 days ago
415 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!