0

I am working on an Android app which uses Dropbox Core SDK v3.0.3. While trying to share a folder with another member, I am constantly getting an error. The code is creating a new shared folder in the specified name, but not adding any members.

This is my code:

List<AddMember> list = new ArrayList<AddMember>();
AddMember newMember = new AddMember(MemberSelector.email(clerkDbId), AccessLevel.EDITOR);
list.add(newMember);
ShareFolderLaunch sfl = dbxClient.sharing().shareFolder("/" + clerkName);
dbxClient.sharing().addFolderMember(sfl.getCompleteValue().toString(), list); //I am getting error here.

clerkName: Name of the shared folder

clerkDbId: Dropbox id to which I want to share the above folder

I tried changing the first line to:

ArrayList<AddMember> list = new ArrayList<>();

Still I am getting the same error. This is the error I am getting:

String 'sharedFolderId' does not match pattern java.lang.IllegalArgumentException: String 'sharedFolderId' does not match pattern at com.dropbox.core.v2.sharing.AddFolderMemberArg.(AddFolderMemberArg.java:50) at com.dropbox.core.v2.sharing.AddFolderMemberArg.(AddFolderMemberArg.java:86) at com.dropbox.core.v2.sharing.DbxUserSharingRequests.addFolderMember(DbxUserSharingRequests.java:154) at com.dbapp.ashworth.adminapp.FilesActivity$3$1.doInBackground(FilesActivity.java:126) at com.dbapp.ashworth.adminapp.FilesActivity$3$1.doInBackground(FilesActivity.java:115) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

Can anyone please tell me what am I doing wrong here?

Dreamist
  • 123
  • 8

1 Answers1

1

The error message is indicating that the sharedFolderId parameter value that you're passing to addFolderMember doesn't appear to be a valid shared folder ID.

You're passing in the entire SharedFolderMetadata (as a string). You should instead just get the shared folder ID like this:

sfl.getCompleteValue().getSharedFolderId();

By the way, when calling shareFolder, you're not guaranteed to get the completed information immediately. You should use ShareFolderLaunch.isComplete/ShareFolderLaunch.isAsyncJobId to check what you got back. There's more information in the shareFolder documentation

Greg
  • 16,359
  • 2
  • 34
  • 44
  • Is it possible to accept a 'share folder' invitation (Add to Dropbox) programmatically? – Dreamist Sep 01 '17 at 17:43
  • Yes, use [`mountFolder`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/sharing/DbxUserSharingRequests.html#mountFolder-java.lang.String-) on the recipient's account. – Greg Sep 01 '17 at 17:53
  • Sorry for asking again. How to get the `sharedFolderId`? The `mountFolder` function requires `sharedFolderId` to mount a folder. Is it necessary to know the folder path? Can you tell me what are the two parameters of `FolderMetadata.newBuilder(name, id)`? – Dreamist Sep 03 '17 at 14:13
  • You can get the `sharedFolderId` from the `SharedFolderMetadata` as above, or you can list all of the available shared folders for mounting in the recipient's connected account using [`listMountableFolders`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/sharing/DbxUserSharingRequests.html#listMountableFolders--)/[`listMountableFoldersContinue`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/sharing/DbxUserSharingRequests.html#listMountableFoldersContinue-java.lang.String-). – Greg Sep 05 '17 at 16:52
  • You don't need to know the original folder path. You specify whatever path for where you want to mount the shared folder in the recipient's account. You also don't need to build `FolderMetadata` yourself, as you can just retrieve it from the various methods. – Greg Sep 05 '17 at 16:53
  • When I am using client.sharing().listFolders().getEntries(), it is returning even deleted folders which are not visible in my Dropbox account. What could be the reason? Is there any solution for this? – Dreamist Sep 08 '17 at 17:45
  • It sounds like you're referring to unmounted folders, per [`ListFoldersResult`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/sharing/ListFoldersResult.html): "Unmounted shared folders can be identified by the absence of `SharedFolderMetadata.getPathLower()`." – Greg Sep 08 '17 at 18:09